Repository navigation
fix(python-sdk): notify on_exit after immediate watch stop - #2072
Elon-Jiang wants to merge 1 commit into
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @Elon-Jiang on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
🦋 Changeset detectedLatest commit: cd02a8c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @Elon-Jiang on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@Elon-Jiang, the CLA check still appears unsuccessful. Is the verification issue already being handled? |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
Summary
Fixes #2071.
await handle.stop()can run immediately afterawait sandbox.files.watch_dir(...), before the handle's background task takes its first step. Cancelling that task prevents_handle_events()from running at all, so its cancellation handler never sendson_exit(None).Have
stop()ensure the exit callback runs after stopping the task and closing the stream. Guard the shared callback helper so repeat stops, normal completion, and a reported stream error cannot send another notification or replace the original error. Async callbacks are still awaited, and callback exceptions retain the existing handling.Add public
Filesystem.watch_dirregressions for immediate stop with sync/async exit callbacks, repeated stops, and stopping after clean/error completion. Include a Python SDK patch changeset.Usage
Validation
Python 3.12.14, main
8cc9ed1e30a57d89cefaec112680567d62f21112:pytest tests/test_*.py -qfrom the Python SDK).Filesystem.watch_dir, the generated RPC client and real SDK codec/interceptors:on_exitruns exactly once after immediate/repeated stop, and the server receivesRST_STREAM CANCEL.pnpm --filter @e2b/python-sdk run format: 444 files unchanged.pnpm --filter @e2b/python-sdk run lint: passed.pnpm --filter @e2b/python-sdk run typecheck: passed.uv buildwith the repository-pinned uv 0.13.4: sdist and wheel passed.The scheduling issue is specific to Python's newly created async task. JS starts its handler in the constructor; sync Python uses polling and has no exit callback. Their implementations are unchanged.
Filesystem.watch_diralready documentson_exit(None)on stop; this restores that existing contract and adds a changelog entry. I could not accesse2b-dev/docs(GitHub API 404), so no separate docs PR is attached.AI assistance was used to investigate, implement, and validate this change.