From d0c42d4cf15b0df25ad7b6c7fe3e915271f26976 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Sat, 13 Jul 2024 11:45:00 -0700 Subject: [PATCH] fix on_start and on_stop Fix: https://github.com/cirospaciari/socketify.py/issues/153 Fix: https://github.com/cirospaciari/socketify.py/issues/140 --- src/socketify/tasks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/socketify/tasks.py b/src/socketify/tasks.py index 656047f..72f4ae8 100644 --- a/src/socketify/tasks.py +++ b/src/socketify/tasks.py @@ -120,10 +120,10 @@ class RequestTask: if self._loop.get_debug(): self._source_traceback = format_helpers.extract_stack(sys._getframe(1)) _register_task(self) - # if current_task(): - # self._loop.call_soon(self.__step, context=self._context) - # else: - self.__step() + if loop.is_running(): + self.__step() + else: + self._loop.call_soon(self.__step, context=self._context) def _reuse(self, coro, loop, default_done_callback=None):