When starting two DockerDeployment containers concurrently using asyncio.gather, the deployment.start() method hangs and eventually fails with a timeout.
This is a simple script to reproduce the issue:
import asyncio
import logging
from swerex.deployment.docker import DockerDeployment
logger = logging.getLogger(__name__)
async def start_container(name: str):
logger.info(f"[{name}] Initializing deployment...")
deployment = DockerDeployment(
image="android-bench-env",
docker_args=["--privileged"]
)
try:
logger.info(f"[{name}] CALLING 'await deployment.start()'...")
await deployment.start()
logger.info(f"--- [{name}] SUCCEEDED ---")
except Exception as e:
logger.exception(f"--- [{name}] FAILED TO START ---")
finally:
logger.info(f"[{name}] Stopping deployment...")
try:
await deployment.stop()
except Exception as e:
logger.error(f"[{name}] Failed to stop deployment", exc_info=True)
async def main():
logger.info("--- Starting two container deployments in parallel ---")
await asyncio.gather(
start_container("Container-1"),
start_container("Container-2"),
return_exceptions=True
)
logger.info("--- Both tasks finished. ---")
if __name__ == "__main__":
asyncio.run(main())
When starting two DockerDeployment containers concurrently using asyncio.gather, the deployment.start() method hangs and eventually fails with a timeout.
This is a simple script to reproduce the issue: