Skip to content

Make system tasks live inside their own contextvars context. - #520

Merged
Fuyukai merged 5 commits into
python-trio:masterfrom
Fuyukai:system-tasks-contextvars
May 6, 2018
Merged

Fuyukai merged 5 commits into
python-trio:masterfrom
Fuyukai:system-tasks-contextvars

Conversation

@Fuyukai

@Fuyukai Fuyukai commented May 5, 2018

Copy link
Copy Markdown
Member

Closes #289.

Re-do of my previous PR, which was a bit too ambitious.

@codecov

codecov Bot commented May 5, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #520 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #520      +/-   ##
==========================================
+ Coverage   99.26%   99.27%   +<.01%     
==========================================
  Files          89       89              
  Lines       10405    10485      +80     
  Branches      721      727       +6     
==========================================
+ Hits        10329    10409      +80     
  Misses         58       58              
  Partials       18       18
Impacted Files Coverage Δ
trio/_core/tests/test_run.py 100% <100%> (ø) ⬆️
trio/_core/_run.py 100% <100%> (ø) ⬆️
trio/_sync.py 100% <0%> (ø) ⬆️
trio/tests/test_sync.py 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c190e2...c4129e6. Read the comment docs.

@njsmith

njsmith commented May 5, 2018

Copy link
Copy Markdown
Member

In case you were curious, the weird yapf stuff is because yapf uses the presence of a trailing comma on the last item as a hint that you want vertical formatting.

@njsmith njsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also we should add a note to the spawn_system_task docs, in the list of differences between system and regular tasks. Otherwise LGTM.

Comment thread newsfragments/289.feature.rst Outdated
@@ -0,0 +1 @@
Make system tasks run in their own context defined at the ``trio.run`` call. No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about:

Tasks created by :func:`~trio.hazmat.spawn_system_task` now no longer inherit the creator's :mod:`contextvars` context.

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wasn't sure what to put for the note, so this sounds a lot better.

@Fuyukai
Fuyukai merged commit aecb85d into python-trio:master May 6, 2018
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.

2 participants