-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around some issues where recording streams leaking context when …
…used with generators (#6240) ### What - Resolves: #6238 In `thread_local_stream`, don't yield while holding the stream context open. Re-create context before continuing the generator. Also introduce a new `recording_stream_generator_ctx` for more advanced usage. This is mainly an escape hatch. The problem from the example can now be handled using: ``` import rerun as rr @rr.recording_stream_generator_ctx def my_gen_func(stream, name): with stream: for i in range(10): print(f"{name} {i}") rr.log("stream", rr.TextLog(f"{name} {i}")) yield rr.init("rerun_example_leak_context") stream1 = rr.new_recording("rerun_example_stream1") stream1.save("stream1.rrd") stream2 = rr.new_recording("rerun_example_stream2") stream2.save("stream2.rrd") gen1 = my_gen_func(stream1, "stream1") gen2 = my_gen_func(stream2, "stream2") next(gen1) next(gen2) rr.log("stream", rr.TextLog("This should go to the global stream")) next(gen1) next(gen1) next(gen1) ``` ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6240?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6240?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/6240) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.
- Loading branch information
Showing
3 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters