utils: fix possible invalide state error while canceling future for abort_on

This commit is contained in:
uael
2023-02-06 16:58:23 +00:00
parent b731f6f556
commit 856a8d53cd

View File

@@ -78,6 +78,8 @@ class AbortableEventEmitter(EventEmitter):
return future return future
def on_event(*_): def on_event(*_):
if future.done():
return
msg = f'abort: {event} event occurred.' msg = f'abort: {event} event occurred.'
if isinstance(future, asyncio.Task): if isinstance(future, asyncio.Task):
# python < 3.9 does not support passing a message on `Task.cancel` # python < 3.9 does not support passing a message on `Task.cancel`