More fixes to Ctrl+C
This commit is contained in:
parent
8d3315d2cb
commit
07dd63dd49
|
@ -365,6 +365,7 @@ class FIFOKernel:
|
||||||
self.debugger.before_task_step(self.current_task)
|
self.debugger.before_task_step(self.current_task)
|
||||||
if self._sigint_handled:
|
if self._sigint_handled:
|
||||||
self._sigint_handled = False
|
self._sigint_handled = False
|
||||||
|
self.current_task.throw(KeyboardInterrupt())
|
||||||
_runner = partial(self.current_task.throw, KeyboardInterrupt)
|
_runner = partial(self.current_task.throw, KeyboardInterrupt)
|
||||||
_data = []
|
_data = []
|
||||||
# Run a single step with the calculation (i.e. until a yield
|
# Run a single step with the calculation (i.e. until a yield
|
||||||
|
@ -431,6 +432,15 @@ class FIFOKernel:
|
||||||
# (no matter what it's doing, because it doesn't really
|
# (no matter what it's doing, because it doesn't really
|
||||||
# matter) and let run_task_step raise an exception inside
|
# matter) and let run_task_step raise an exception inside
|
||||||
# it
|
# it
|
||||||
|
|
||||||
|
# P.S.: Okay, so, I never liked this code here because it
|
||||||
|
# is really hard to test properly in different contexts: while
|
||||||
|
# it's true that it's technically okay for us to raise KeyboardInterrupt
|
||||||
|
# anywhere in the user's code, simplifying the critical path and making it
|
||||||
|
# behave more predictably has priority. Also, if trio can afford to be lazy,
|
||||||
|
# then so can we. Besides, the loop's entry point _is_ technically part of
|
||||||
|
# where KeyboardInterrupt is allowed to pop up
|
||||||
|
"""
|
||||||
task: Task | None = None
|
task: Task | None = None
|
||||||
if self.selector.get_map():
|
if self.selector.get_map():
|
||||||
# Pretty convoluted, huh? Sorry, but I wanted this on one line ;)
|
# Pretty convoluted, huh? Sorry, but I wanted this on one line ;)
|
||||||
|
@ -439,6 +449,8 @@ class FIFOKernel:
|
||||||
task, *_ = self.paused.get()
|
task, *_ = self.paused.get()
|
||||||
else:
|
else:
|
||||||
task = self.current_task
|
task = self.current_task
|
||||||
|
"""
|
||||||
|
task = self.entry_point
|
||||||
self.run_ready.appendleft(task)
|
self.run_ready.appendleft(task)
|
||||||
self.handle_errors(self.run_task_step)
|
self.handle_errors(self.run_task_step)
|
||||||
elif not self.run_ready:
|
elif not self.run_ready:
|
||||||
|
|
Reference in New Issue