Compare commits
2 Commits
e423716442
...
98a280ce39
Author | SHA1 | Date |
---|---|---|
Mattia Giambirtone | 98a280ce39 | |
Mattia Giambirtone | dd924d600c |
|
@ -67,13 +67,13 @@ class TaskScope:
|
|||
return self
|
||||
|
||||
async def __aexit__(self, exc_type: type, exception: Exception, tb):
|
||||
await close_scope(self)
|
||||
if self.timeout and not self.waiter.done():
|
||||
# Well, looks like we finished before our worker.
|
||||
# Thanks for your help! Now die.
|
||||
self.timeout_scope.cancellable = True
|
||||
await cancel(self.waiter, block=True)
|
||||
# Task scopes are sick: Nathaniel, you're an effing genius.
|
||||
await close_scope(self)
|
||||
if isinstance(exception, TimeoutError) and self.timed_out:
|
||||
# This way we only silence our own timeouts and not
|
||||
# someone else's!
|
||||
|
|
|
@ -582,10 +582,10 @@ class FIFOKernel:
|
|||
if not task.scope or task.scope.cancellable:
|
||||
self.paused.discard(task)
|
||||
self.io_release_task(task)
|
||||
self.run_ready.append(task)
|
||||
self.handle_errors(partial(task.throw, Cancelled(task)), task)
|
||||
if task.state != TaskState.CANCELLED:
|
||||
task.pending_cancellation = True
|
||||
self.run_ready.append(task)
|
||||
self.reschedule_running()
|
||||
|
||||
def throw(self, task, error):
|
||||
|
@ -595,7 +595,7 @@ class FIFOKernel:
|
|||
|
||||
task.pending_exception = error
|
||||
self.run_ready.appendleft(task)
|
||||
self.handle_errors(partial(task.throw, error), task)
|
||||
self.handle_errors(self.run_task_step)
|
||||
self.reschedule_running()
|
||||
|
||||
def handle_errors(self, func: Callable, task: Task | None = None):
|
||||
|
|
Reference in New Issue