Raise deferred KeyboardInterrupt out of run() after cancelling all tasks#1537
Raise deferred KeyboardInterrupt out of run() after cancelling all tasks#1537oremanj wants to merge 11 commits intopython-trio:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1537 +/- ##
==========================================
- Coverage 99.67% 99.67% -0.01%
==========================================
Files 108 108
Lines 13358 13345 -13
Branches 1012 1008 -4
==========================================
- Hits 13315 13302 -13
Misses 28 28
Partials 15 15
|
|
The coverage "failure" is because |
|
Sorry for the merge conflict, I just merged the Black pull request |
|
I'm not sure cancelling the system nursery is a great idea... until now, we had an invariant that system tasks would only be cancelled (a) after the main task exited, or (b) after a system task crashed. So they basically had the "service task" semantics discussed in #1521. I feel like |
|
That makes sense to me, but I think it will be easiest to implement by just doing #1521, because I don't see any way to wrap the main task in a dedicated cancel scope without adding another frame to every Trio traceback. |
|
Maybe possibly we could do something like this? async def init(self, async_fn, args):
async with open_nursery() as system_nursery:
self.system_nursery = system_nursery
async with open_nursery() as main_task_nursery: ##### <-----
try:
self.main_task = self.spawn_impl(async_fn, args, main_task_nursery, None)
except BaseException as exc:
self.main_task_outcome = Error(exc)
system_nursery.cancel_scope.cancel()
self.entry_queue.spawn()but yeah, I see your point |
@oremanj Well now we have Also you will probably have to start the PR from scratch as it is out of date. Also I think this fixes #2649 |
Co-authored-by: Joshua Oreman <4316136+oremanj@users.noreply.github.com>
Fixes #151, first step of #733.