pass event loop explicitly to callback to avoid runtime error

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I0d899d6068d78c20c96b930b73173cc76a6a6964
This commit is contained in:
raf 2026-04-07 13:24:20 +03:00
commit 6af8fbcac7
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -13,6 +13,7 @@ from flipoff.gesture import GestureRegistry
def _get_callback(
loop: asyncio.AbstractEventLoop,
gesture_cls: type[Gesture],
event_instance: object,
cooldown: float,
@ -24,7 +25,7 @@ def _get_callback(
now = time.time()
if now - last_trigger[0] > cooldown:
last_trigger[0] = now
asyncio.create_task(event_instance.trigger()) # type: ignore[attr-defined]
loop.create_task(event_instance.trigger()) # type: ignore[attr-defined]
return gesture_detected
return callback
@ -59,7 +60,7 @@ def run(
gesture_instance = gesture_cls()
last_trigger = [0.0]
callback = _get_callback(gesture_cls, event_instance, cooldown, last_trigger)
callback = _get_callback(loop, gesture_cls, event_instance, cooldown, last_trigger)
while True:
ret, frame = camera.read()