-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
Simplified nurseries #375
Simplified nurseries #375
Conversation
- Parenting is no longer a full time job - This commit also removes a bunch of deprecated functions Fixes: python-triogh-136
Codecov Report
@@ Coverage Diff @@
## master #375 +/- ##
==========================================
+ Coverage 99.24% 99.31% +0.06%
==========================================
Files 87 87
Lines 10443 10334 -109
Branches 728 714 -14
==========================================
- Hits 10364 10263 -101
+ Misses 61 56 -5
+ Partials 18 15 -3
Continue to review full report at Codecov.
|
I don't think there's any way this could have led to a spurious reschedule, but now I'm even more certain.
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.
Played a bit with it, works pretty well !
docs/source/reference-core.rst
Outdated
to the ``racecar`` function to catch exceptions and handle them | ||
however you like. | ||
nursery.start_soon(jockey, async_fn) | ||
winner = await q.get() |
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.
IIUC this should run after the loop, not inside it.
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.
Nice catch! Fixed.
Thanks to Ran Benita.
Closing/reopening to restart Travis build affected by #379 |
The rationale for the previous behavior (parenting is full-time task) was:
This made sense to me. Now if we look at this example with the new approach: async def parent(handler):
try:
async with trio.open_nursery() as nursery:
nursery.start_soon(some_task)
await trio.sleep(inf)
except Exception:
pass
print('This will be reached') If If I want to perform cancellation cleanup for the "pseudo-task", will the following work? async def parent(handler):
async def some_task(cancel_scope):
await trio.sleep(1)
cancel_scope.cancel()
async with trio.open_nursery() as nursery:
nursery.start_soon(some_task, nursery.cancel_scope)
try:
await trio.sleep(inf)
except trio.Cancelled:
# some cleanup...
raise
print('This will be reached') |
(I've made some edits to the question above, if you're reading from mail). |
Yeah, that looks correct. Of course in many cases a I'm not sure if there's something better we can be doing here. |
Guess this has marinated long enough :-) |
Is there some essay on what "parenting is a full-time task" and "parenting is not a full-time task" mean, including rationale for each approach? I haven't recursed through the linked issues or looked at the code changes themselves, but from just this issue discussion and my beginner-level familiarity with using trio, I have no idea what exactly is being expressed here (besides the partial but incomplete narrowing down of possible meanings that I can infer from the above example). |
Oh okay the diff contains documentation changes that seem to clarify it a bit. You can just ignore my last comment. |
Fixes: gh-136