-
Notifications
You must be signed in to change notification settings - Fork 178
Update e2b dependency to latest version #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jakub.dobry <[email protected]>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: jakub.dobry <[email protected]>
Co-authored-by: jakub.dobry <[email protected]>
Co-authored-by: jakub.dobry <[email protected]>
Co-authored-by: jakub.dobry <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @pytest.fixture | ||
| def async_sandbox_factory(request, template, debug, event_loop): | ||
| """Factory for creating async sandboxes with proper cleanup.""" | ||
|
|
||
| try: | ||
| yield async_sandbox | ||
| finally: | ||
| try: | ||
| await async_sandbox.kill() | ||
| except: # noqa: E722 | ||
| if not debug: | ||
| warning( | ||
| "Failed to kill sandbox — this is expected if the test runs with local envd." | ||
| ) | ||
| async def factory(template_override=None, **kwargs): | ||
| template_name = template_override or template | ||
| kwargs.setdefault("timeout", timeout) | ||
| kwargs.setdefault("debug", debug) | ||
|
|
||
| sandbox = await AsyncSandbox.create(template_name, **kwargs) | ||
|
|
||
| def kill(): | ||
| async def _kill(): | ||
| try: | ||
| await sandbox.kill() | ||
| except: # noqa: E722 | ||
| if not debug: | ||
| warning( | ||
| "Failed to kill sandbox — this is expected if the test runs with local envd." | ||
| ) | ||
|
|
||
| event_loop.run_until_complete(_kill()) | ||
|
|
||
| request.addfinalizer(kill) | ||
| return sandbox | ||
|
|
||
| return factory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run sandbox teardown on the loop that created it
The finalizer registered in async_sandbox_factory always uses the session-scoped event_loop to execute sandbox.kill(). However, the sandbox itself is created on whatever loop is running the fixture/test. With pytest-asyncio 0.24’s default asyncio_mode=auto, each async test runs inside its own asyncio.run loop, so the sandbox is bound to that per-test loop. Executing its teardown on a different loop raises RuntimeError: Task/Future attached to a different loop, which prevents the sandbox from being killed and leaks resources. Store the loop used during creation (e.g., via asyncio.get_running_loop()) and run the cleanup on that loop, or perform the cleanup in an async finalizer instead of switching loops.
Useful? React with 👍 / 👎.
Update e2b dependency to version 2.7.0 for both JavaScript and Python projects.
Slack Thread
Note
Updates e2b to 2.7.0 across JS/Python and refactors Python async test fixtures (session event loop, factory) with pytest deps bumped.
e2bto^2.7.0injs/package.json.e2bto^2.7.0inpython/pyproject.toml; update dev depspytestto^8.2.0andpytest-asyncioto^0.24.0.event_loopfixture to prevent "Event loop is closed" issues (better xdist compatibility).async_sandboxfixture withasync_sandbox_factoryand a defaultasync_sandboxusing it; ensure async teardown via finalizer and event loop run.Written by Cursor Bugbot for commit b32245f. This will update automatically on new commits. Configure here.