Skip to content

Bug: DockerDeployment.start() times out when run in parallel with asyncio.gather #261

Description

@vgakhreja-google

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())

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions