diff --git a/modal/sandbox.py b/modal/sandbox.py index aed5c8df4..883e7f202 100644 --- a/modal/sandbox.py +++ b/modal/sandbox.py @@ -199,7 +199,7 @@ async def create( _experimental_gpus=_experimental_gpus, ) if client is None: - if app: + if app and app._client: client = app._client else: client = await _Client.from_env() diff --git a/test/sandbox_test.py b/test/sandbox_test.py index eae1613d1..4dbc865e7 100644 --- a/test/sandbox_test.py +++ b/test/sandbox_test.py @@ -36,6 +36,14 @@ def test_sandbox(client, servicer): assert sb.poll() == 42 +@skip_non_linux +def test_app_attached_from_env(set_env_client): + sb = Sandbox.create("echo", "hi", app=app) + sb.wait() + + assert sb.stdout.read() == "hi\n" + + @skip_non_linux def test_sandbox_mount(client, servicer, tmpdir): tmpdir.join("a.py").write(b"foo")