oremanj / greenback

Reenter an asyncio or Trio event loop from synchronous code
https://greenback.readthedocs.io/
Other
77 stars 2 forks source link

Add with_portal_run_tree() and has_portal() #9

Closed oremanj closed 2 years ago

oremanj commented 2 years ago

with_portal_run_tree() is like with_portal_run() except that it "infects" child tasks also: any task underneath it in the call tree can use await_(). Trio only.

has_portal() just queries whether a task already has a portal set up.

Fix bestow_portal() so it doesn't need to be run in the top-level greenlet, because that was easy to screw up (any task with a portal set up is not running in the top-level greenlet) and created extremely confusing errors (one task's traps would get delivered to another task, more or less at random).

codecov[bot] commented 2 years ago

Codecov Report

Merging #9 (5eb377e) into master (532ba6f) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #9   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          612       697   +85     
  Branches        79        92   +13     
=========================================
+ Hits           612       697   +85     
Flag Coverage Δ
cpython 98.85% <100.00%> (+0.15%) :arrow_up:
pypy36release 93.59% <97.02%> (-0.11%) :arrow_down:

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

Impacted Files Coverage Δ
greenback/__init__.py 100.00% <ø> (ø)
greenback/_impl.py 100.00% <100.00%> (ø)
greenback/_tests/test_impl.py 100.00% <100.00%> (ø)
greenback/_util.py 100.00% <100.00%> (ø)

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 532ba6f...5eb377e. Read the comment docs.