我正在尝试创建一个自定义异常处理程序,以便在asynio
中的协同例程引发Exception
时重新启动连接。在
有一个合作计划,比如:
@asyncio.coroutine
def process_notification(device):
results = yield from get_notifications(device)
# here I am creating other tasks
return result
自定义异常处理程序的定义如下:
^{pr2}$在应用程序中:
...
loop = asyncio.get_event_loop()
loop.set_exception_handler(custom_exception_handler)
task = asyncio.ensure_future(process_notification(device))
...
如图所示,在TODO中,我缺少如何从任务初始调用获取参数。在
目前没有回答
相关问题 更多 >
编程相关推荐