The loop now removes exited tasks from self.tasks

This commit is contained in:
nocturn9x 2021-08-27 09:04:26 +02:00
parent e4a4c45f65
commit a472116686
1 changed files with 3 additions and 0 deletions

View File

@ -228,6 +228,7 @@ class AsyncScheduler:
self.current_task.result = ret.value
self.current_task.finished = True
self.join(self.current_task)
self.tasks.remove(self.current_task)
except BaseException as err:
# Our handy join mechanism will handle all the hassle of
# rescheduling joiners and propagating errors, so we
@ -235,6 +236,7 @@ class AsyncScheduler:
# self.join() work its magic
self.current_task.exc = err
self.join(self.current_task)
self.tasks.remove(self.current_task)
def create_task(self, corofunc: types.FunctionType, pool, *args, **kwargs) -> Task:
"""
@ -687,6 +689,7 @@ class AsyncScheduler:
task.status = "cancelled"
self.io_release_task(self.current_task)
self.debugger.after_cancel(task)
self.tasks.remove(self.current_task)
else:
# If the task ignores our exception, we'll
# raise it later again