Skip to content

Commit 08c1369

Browse files
committed
fix: use BoundEvent.put() in engine error handlers to avoid unawaited coroutine warnings
The error handlers _on_error_handler() and _send_error_execution() used sm.send() which triggers _processing_loop() — creating an unawaited coroutine in AsyncEngine. Since these are always called within an active macrostep, BoundEvent.put() is sufficient to enqueue the error.execution event on the internal queue without the redundant processing loop call.
1 parent d19a0a4 commit 08c1369

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

statemachine/engines/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def handler(error: Exception) -> None:
159159
# new error.execution is a separate event that may trigger a different
160160
# transition (see W3C test 152). The infinite-loop guard lives at the
161161
# *microstep* level (in ``_send_error_execution``), not here.
162-
self.sm.send(_ERROR_EXECUTION, error=error, internal=True)
162+
BoundEvent(_ERROR_EXECUTION, internal=True, _sm=self.sm).put(error=error)
163163

164164
return handler
165165

@@ -188,7 +188,7 @@ def _send_error_execution(self, error: Exception, trigger_data: TriggerData):
188188
if trigger_data.event and str(trigger_data.event) == _ERROR_EXECUTION:
189189
logger.warning("Error while processing error.execution, ignoring: %s", error)
190190
return
191-
self.sm.send(_ERROR_EXECUTION, error=error, internal=True)
191+
BoundEvent(_ERROR_EXECUTION, internal=True, _sm=self.sm).put(error=error)
192192

193193
def start(self, **kwargs):
194194
if self.sm.current_state_value is not None:

0 commit comments

Comments
 (0)