From daca2e90bf6d465b5bad6d15d51cfdcdb851944f Mon Sep 17 00:00:00 2001 From: Matvey Kukuy Date: Mon, 30 Dec 2024 13:37:04 +0100 Subject: [PATCH] Fix --- keep/workflowmanager/workflowscheduler.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/keep/workflowmanager/workflowscheduler.py b/keep/workflowmanager/workflowscheduler.py index f7b51e162..7083ec6ee 100644 --- a/keep/workflowmanager/workflowscheduler.py +++ b/keep/workflowmanager/workflowscheduler.py @@ -617,8 +617,7 @@ async def _handle_event_workflows(self): ) - async def _start(self): - self.logger.info("Starting workflows scheduler") + async def _start_async(self): while not self._stop: # get all workflows that should run now self.logger.debug( @@ -637,6 +636,17 @@ async def _start(self): await asyncio.sleep(1) self.logger.info("Workflows scheduler stopped") + def _start(self): + """ + Generating new event loop and running the scheduler. + This method should be executed in a separate thread. + """ + self.logger.info("Starting workflows scheduler") + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + result = loop.run_until_complete(self._start_async()) + loop.close() + return result def stop(self): self.logger.info("Stopping scheduled workflows")