Skip to content

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Nov 15, 2025

Update e2b dependency to version 2.7.0 for both JavaScript and Python projects.


Slack Thread

Open in Cursor Open in Web


Note

Updates e2b to 2.7.0 across JS/Python and refactors Python async test fixtures (session event loop, factory) with pytest deps bumped.

  • Dependencies:
    • JavaScript: Bump e2b to ^2.7.0 in js/package.json.
    • Python: Bump e2b to ^2.7.0 in python/pyproject.toml; update dev deps pytest to ^8.2.0 and pytest-asyncio to ^0.24.0.
  • Python Tests:
    • Add session-scoped event_loop fixture to prevent "Event loop is closed" issues (better xdist compatibility).
    • Replace async_sandbox fixture with async_sandbox_factory and a default async_sandbox using 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.

@cursor
Copy link

cursor bot commented Nov 15, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@dobrac dobrac marked this pull request as ready for review November 15, 2025 23:35
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines +48 to +74
@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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants