Skip to content

Commit a779577

Browse files
committed
fix: await async send() in invoke handlers to avoid unawaited coroutine warnings
The async invoke handler (_run_async_handler) called sm.send() without await for done.invoke and error.execution events, creating unawaited coroutines from AsyncEngine.processing_loop().
1 parent 08c1369 commit a779577

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

statemachine/invoke.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ async def _run_async_handler(
455455
None, lambda: callback.call(ctx=ctx, machine=ctx.machine, **ctx.kwargs)
456456
)
457457
if not ctx.cancelled.is_set():
458-
self.sm.send(
458+
await self.sm.send(
459459
f"done.invoke.{ctx.invokeid}",
460460
data=result,
461461
)
@@ -466,7 +466,7 @@ async def _run_async_handler(
466466
except Exception as e:
467467
if not ctx.cancelled.is_set():
468468
# External queue — see comment in _run_sync_handler.
469-
self.sm.send("error.execution", error=e)
469+
await self.sm.send("error.execution", error=e)
470470
finally:
471471
invocation.terminated = True
472472
logger.debug(

0 commit comments

Comments
 (0)