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
Fix annotations and spans leaking between threads #10367
Fix annotations and spans leaking between threads #10367
Conversation
e8ac766
to
dfe06a4
Compare
dfe06a4
to
ff86f8f
Compare
Initially, I was going to create a module for this code called Line 1 in a6ee367
The name would be clashing, so for now, I left it in |
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.
Can you please add a test for this as well somewhere? #10340 provides an example that triggers this leakage w/out spans and I'd like to test this behavior.
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.
Missing unit tests:
- the code inside
with dask.annotate()
raises - annotations in two different asyncio tasks or threads[1] running in parallel do not interfere with each other
[1] only need one. Pick whatever is easier/cleaner to write.
Please add line to |
dask/tests/test_highgraph.py
Outdated
with dask.annotate(banana=5): | ||
with dask.annotate(apple=3): | ||
with pytest.raises(ZeroDivisionError): | ||
_ = 1 / 0 |
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.
The exception is being swallowed by pytest.raises and never reaches dask.annotate.
dask/tests/test_highgraph.py
Outdated
@@ -186,10 +186,19 @@ def test_annotation_and_config_collision(): | |||
with dask.config.set({"foo": 1}): | |||
with dask.annotate(foo=2): | |||
assert dask.config.get("foo") == 1 | |||
assert dask.config.get("annotations") == {"foo": 2} | |||
assert dask.get_annotations() == {"foo": 2} |
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.
This test no longer makes sense
0f67385
to
561f501
Compare
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.
Missing unit test:
annotations in two different asyncio tasks or threads[1] running in parallel do not interfere with each other.
[1] only need one. Pick whatever is easier/cleaner to write.
296ff00
to
26d6f0a
Compare
I added a test called |
|
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.
This is ready to be merged as soon as you revert the temporary CI changes in dask/distributed#7935
Switch global annotations to use
ContextVar
instead of setting values in dask config.Dependent PR in distributed: dask/distributed#7935
pre-commit run --all-files
cc @fjetter @crusaderky