Message336265
I do not think this is a bug. Any exception that is raised inside a task will be in the .exception() method when the task is finished. Here you are running the task without waiting for finalization. For example, if you change:
async def cofunc1(self):
await self.cofunc2()
await self.task # <-------------
print("\nwaitin' : where-t-f is the NameError hiding!?")
await asyncio.sleep(6)
print("Wait is over, let's exit\n")
you will find the NameError immediately. If you do not want to await the task you can wait until self.task.done() is True and then check self.task.exception() for retrieving the exception (if any).
What happens with BaseException is that is a very low-level exception that is handled differently compared with regular exceptions that derive from Exception. The reason is that control flow exceptions and things like KeyboardInterrupt need to be handled differently. This happens explicitly here:
https://github.com/python/cpython/blob/master/Modules/_asynciomodule.c#L2675 |
|
Date |
User |
Action |
Args |
2019-02-21 21:50:42 | pablogsal | set | recipients:
+ pablogsal, asvetlov, yselivanov, eamanu, Sampsa Riikonen |
2019-02-21 21:50:42 | pablogsal | set | messageid: <1550785842.03.0.529177732355.issue35867@roundup.psfhosted.org> |
2019-02-21 21:50:42 | pablogsal | link | issue35867 messages |
2019-02-21 21:50:41 | pablogsal | create | |
|