Skip to content

Commit

Permalink
Fix empty client behavior with app-attached sandboxes
Browse files Browse the repository at this point in the history
Previously, if a clientless app was attached to a sandbox, it would
error with NoneType. This commit checks app._client to make sure it
exists before using it.
  • Loading branch information
pawalt committed Sep 3, 2024
1 parent ff533ee commit bb54004
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modal/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions test/sandbox_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit bb54004

Please sign in to comment.