In regular Python, I can retrieve the result of a task using the .result() method:
Code: Select all
t = asyncio.create_task(sometask())
await t
print('result:', t.result())
uasyncio.Task objects don't have a .result() method, but they do have a .data attribute, and when .done is true, .data.value appears to have the task result. This isn't documented anywhere; can I rely on it? It's useful when trying to implement something like asyncio.wait() or asyncio.as_completed(), where one wants to return the task object but calling code may want the task result.