extmod/uasyncio: Add Task.done() method.

This is added because task.coro==None is no longer the way to detect if a
task is finished.  Providing a (CPython compatible) function for this
allows the implementation to be abstracted away.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2020-11-30 17:38:30 +11:00
parent ca40eb0fda
commit 309dfe39e0
4 changed files with 102 additions and 0 deletions

View File

@@ -148,6 +148,9 @@ class Task:
# Set calling task's data to this task that it waits on, to double-link it.
core.cur_task.data = self
def done(self):
return self.coro is self
def cancel(self):
# Check if task is already finished.
if self.coro is self: