Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/deno_sandbox/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,14 @@ async def create(
if sandbox_id is None:
raise Exception("Sandbox ID not found in response headers")

sandbox = None
try:
rpc = AsyncRpcClient(transport)
yield AsyncSandbox(self._client, rpc, sandbox_id)
sandbox = AsyncSandbox(self._client, rpc, sandbox_id)
yield sandbox
finally:
await transport.close()
if sandbox is not None:
await sandbox.close()

@asynccontextmanager
async def connect(
Expand All @@ -210,11 +213,14 @@ async def connect(
},
)

sandbox = None
try:
rpc = AsyncRpcClient(transport)
yield AsyncSandbox(self._client, rpc, sandbox_id)
sandbox = AsyncSandbox(self._client, rpc, sandbox_id)
yield sandbox
finally:
await transport.close()
if sandbox is not None:
await sandbox.close()

async def list(
self, options: Optional[SandboxListOptions] = None
Expand Down