File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -184,11 +184,14 @@ async def create(
184184 if sandbox_id is None :
185185 raise Exception ("Sandbox ID not found in response headers" )
186186
187+ sandbox = None
187188 try :
188189 rpc = AsyncRpcClient (transport )
189- yield AsyncSandbox (self ._client , rpc , sandbox_id )
190+ sandbox = AsyncSandbox (self ._client , rpc , sandbox_id )
191+ yield sandbox
190192 finally :
191- await transport .close ()
193+ if sandbox is not None :
194+ await sandbox .close ()
192195
193196 @asynccontextmanager
194197 async def connect (
@@ -210,11 +213,14 @@ async def connect(
210213 },
211214 )
212215
216+ sandbox = None
213217 try :
214218 rpc = AsyncRpcClient (transport )
215- yield AsyncSandbox (self ._client , rpc , sandbox_id )
219+ sandbox = AsyncSandbox (self ._client , rpc , sandbox_id )
220+ yield sandbox
216221 finally :
217- await transport .close ()
222+ if sandbox is not None :
223+ await sandbox .close ()
218224
219225 async def list (
220226 self , options : Optional [SandboxListOptions ] = None
You can’t perform that action at this time.
0 commit comments