test(python-sdk): parallelize async sandbox teardown#1309
test(python-sdk): parallelize async sandbox teardown#1309mishushakov wants to merge 1 commit intomainfrom
Conversation
Use asyncio.gather with return_exceptions so a failed kill() on one sandbox doesn't block cleanup of the rest, and teardown runs concurrently. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
PR SummaryLow Risk Overview Also moves the Reviewed by Cursor Bugbot for commit b433ef4. Bugbot is set up for automated code reviews on this repo. Configure here. |
Package ArtifactsBuilt from 43cb9b9. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.19.5-mishushakov-async-teardown-fix.0.tgzCLI ( npm install ./e2b-cli-2.10.2-mishushakov-async-teardown-fix.0.tgzPython SDK ( pip install ./e2b-2.20.3+mishushakov.async.teardown.fix-py3-none-any.whl |
There was a problem hiding this comment.
LGTM — straightforward test fixture cleanup parallelization.
Extended reasoning...
Overview
This PR modifies a single test fixture file (packages/python-sdk/tests/conftest.py) in the async_sandbox_factory fixture. It replaces a sequential for sandbox in sandboxes: await sandbox.kill() teardown loop with asyncio.gather(..., return_exceptions=True) for concurrent cleanup, and hoists the _test_failed check above the loop so the failure log prints once per fixture rather than per sandbox.
Security risks
None. This is test-only code (tests/conftest.py), not shipped or used in production. There is no auth, crypto, or permissions logic involved.
Level of scrutiny
Low scrutiny is appropriate. The change is a small, mechanical optimization to test teardown logic. return_exceptions=True preserves the previous swallow-errors behavior of the original try/except, so semantics are preserved while gaining concurrency. The hoisted _test_failed check is a clear correctness improvement (avoids duplicated log lines).
Other factors
The change is self-contained, limited to ~10 lines, and follows an established pattern. The changeset-bot warning about no changeset is expected and acceptable for a test-only change. No bugs were flagged by the bug hunting system.
Summary
for sandbox in sandboxes: await sandbox.kill()teardown inasync_sandbox_factorywithasyncio.gather(..., return_exceptions=True)so a failure on one kill no longer blocks cleanup of the rest, and teardown runs concurrently._test_failedcheck above the loop so the failure log is printed once per fixture rather than per sandbox.Test plan
pnpm run format,pnpm run lint,pnpm run typecheck(python-sdk) all passpnpm run testagainst affected python async sandbox tests🤖 Generated with Claude Code