From 856a8d53cda34a93d6980bc4a5905281e7a8ce7c Mon Sep 17 00:00:00 2001 From: uael Date: Mon, 6 Feb 2023 16:58:23 +0000 Subject: [PATCH] utils: fix possible invalide state error while canceling future for `abort_on` --- bumble/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bumble/utils.py b/bumble/utils.py index 6f811f7d..111f0556 100644 --- a/bumble/utils.py +++ b/bumble/utils.py @@ -78,6 +78,8 @@ class AbortableEventEmitter(EventEmitter): return future def on_event(*_): + if future.done(): + return msg = f'abort: {event} event occurred.' if isinstance(future, asyncio.Task): # python < 3.9 does not support passing a message on `Task.cancel`