python3.6.7 ::优雅地处理RuntimeError错误

时间:2019-08-06 21:21:28

标签: python-3.x python-asyncio

是否有一种优雅的方式来处理错误,因为这会掩盖实际的RuntimeError错误

async def clean_up_process_wrapper(app):
    while app.is_running:
        await(sleep(0.1))
        try:
            await asyncio.gather(*[system_object['start_cleanup_process'] for system_object in app['State_Machine_Container'].values()])
        except RuntimeError:
            pass

  File "/Users/vchauhan/DEV/dvmt-event-processor/dvmt_event_processor/app.py", line 367, in clean_up_process_wrapper
    await asyncio.gather(*[system_object['start_cleanup_process'] for system_object in app['State_Machine_Container'].values()])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/coroutines.py", line 126, in send
    return self.gen.send(value)
RuntimeError: cannot reuse already awaited coroutine

0 个答案:

没有答案