私はプロジェクトに asyncio を使用していましたが、この奇妙な動作に遭遇しました。
import asyncio
def schedule_something():
global f
tsk = asyncio.async(do_something())
f = tsk #If this line is commented out, exceptions can be heard.
@asyncio.coroutine
def do_something():
raise Exception()
loop = asyncio.get_event_loop()
loop.call_soon(schedule_something)
loop.run_forever()
loop.close()
何らかの理由で、呼び出し時に結果のタスクを保存すると、asyncio.async()
例外が何も実行されなくなります。
誰かがこの状況に光を当てることができますか? 現在のプロジェクトで例外をキャッチする方法が必要です。