def METHOD_NAME(self, container):
    while True:
        try:
            container.stop()
            container.remove()
            LOG.info(f"Stopped container {container.name}")
            break
        except docker.errors.NotFound:
            break
        except docker.errors.APIError:
            # Container may already be in the process of being cleaned up
            time.sleep(0.5)
            continue