Closed SomberNight closed 6 years ago
How does this achieve something not achieved by the call to _add_task immediately below? Is it possible to add a test for the difference?
Maybe it adds some insight if I start by saying:
with report_crash=True
, the crash gets printed twice :)
example:
import asyncio
from aiorpcx import TaskGroup
async def main():
print("main entered")
try:
async with TaskGroup() as group:
await group.spawn(forever())
await group.spawn(f())
finally:
print("main finished")
async def f():
print("f entered")
raise Exception("asd")
async def forever():
while True:
await asyncio.sleep(1)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
log:
main entered
f entered
ERROR:root:task crashed: <Task finished coro=<f() done, defined at <stdin>:1> exception=Exception('asd',)> from callback: True
Traceback (most recent call last):
File "q:\prog\misc\aiorpcx\aiorpcx\util.py", line 118, in check_task
task.result()
File "<stdin>", line 3, in f
Exception: asd
ERROR:TaskGroup:task crashed: <Task finished coro=<f() done, defined at <stdin>:1> exception=Exception('asd',)> from callback: False
Traceback (most recent call last):
File "q:\prog\misc\aiorpcx\aiorpcx\util.py", line 118, in check_task
task.result()
File "q:\prog\misc\aiorpcx\aiorpcx\util.py", line 118, in check_task
task.result()
File "<stdin>", line 3, in f
Exception: asd
main finished
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\asyncio\base_events.py", line 468, in run_until_complete
return future.result()
File "<stdin>", line 6, in main
File "q:\prog\misc\aiorpcx\aiorpcx\curio.py", line 245, in __aexit__
await self.join(wait=self._wait)
File "q:\prog\misc\aiorpcx\aiorpcx\curio.py", line 218, in join
raise task.exception()
File "q:\prog\misc\aiorpcx\aiorpcx\util.py", line 118, in check_task
task.result()
File "q:\prog\misc\aiorpcx\aiorpcx\util.py", line 118, in check_task
task.result()
File "<stdin>", line 3, in f
Exception: asd
Coverage decreased (-0.2%) to 99.753% when pulling ed27e17e7d7c18a1e456c770fcefb12f51aef97c on SomberNight:report_crash into d39fb0ef00824edda0aede2858dc3ab839620fdf on kyuupichan:master.