Skip to content
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

Add TreeVar #18

Merged
merged 2 commits into from
Jun 5, 2023
Merged

Add TreeVar #18

merged 2 commits into from
Jun 5, 2023

Conversation

oremanj
Copy link
Owner

@oremanj oremanj commented Jun 5, 2023

A TreeVar acts like a context variable that is inherited at nursery creation time (and then by child tasks of that nursery) rather than at task creation time. They are useful for providing 'ambient' access to a resource that is tied to an async with block in the parent task, such as an open file or trio-asyncio event loop.

Prior art: python-trio/trio#1543 (never made it into mainline Trio). The implementation without Trio core support is somewhat less efficient, but still workable.

A TreeVar acts like a context variable that is inherited at nursery creation time (and then by child tasks of that nursery) rather than at task creation time. They are useful for providing 'ambient' access to a resource that is tied to an `async with` block in the parent task, such as an open file or trio-asyncio event loop.

Prior art: python-trio/trio#1543 (never made it into mainline Trio). The implementation without Trio core support is somewhat less efficient, but still workable.
@codecov
Copy link

codecov bot commented Jun 5, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.64 🎉

Comparison is base (341eb32) 99.27% compared to head (951716c) 99.92%.

❗ Current head 951716c differs from pull request most recent head f8ddc62. Consider uploading reports for the commit f8ddc62 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #18      +/-   ##
==========================================
+ Coverage   99.27%   99.92%   +0.64%     
==========================================
  Files          13       15       +2     
  Lines        1104     1312     +208     
  Branches      182      216      +34     
==========================================
+ Hits         1096     1311     +215     
+ Misses          5        0       -5     
+ Partials        3        1       -2     
Flag Coverage Δ
3.10 99.92% <100.00%> (?)
3.11 99.92% <100.00%> (?)
3.7 99.92% <100.00%> (?)
3.8 99.92% <100.00%> (?)
3.9 99.92% <100.00%> (?)
Ubuntu 99.92% <100.00%> (?)
Windows 99.92% <100.00%> (?)
macOS 99.92% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tricycle/__init__.py 100.00% <100.00%> (ø)
tricycle/_meta.py 100.00% <100.00%> (+8.06%) ⬆️
tricycle/_rwlock.py 100.00% <100.00%> (+1.55%) ⬆️
tricycle/_service_nursery.py 100.00% <100.00%> (ø)
tricycle/_tests/test_meta.py 100.00% <100.00%> (ø)
tricycle/_tests/test_streams.py 99.49% <100.00%> (-0.01%) ⬇️
tricycle/_tests/test_tree_var.py 100.00% <100.00%> (ø)
tricycle/_tree_var.py 100.00% <100.00%> (ø)
tricycle/_version.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@oremanj oremanj force-pushed the treevar branch 3 times, most recently from 72b5190 to 951716c Compare June 5, 2023 19:48
@oremanj oremanj merged commit 66be686 into master Jun 5, 2023
@oremanj oremanj deleted the treevar branch June 5, 2023 19:56
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.

1 participant