From bd093b24f50f290faaee7a35f7822ee5c777c3a9 Mon Sep 17 00:00:00 2001 From: yair Date: Wed, 16 Oct 2024 09:51:17 +0300 Subject: [PATCH] switched while true to call later --- port_ocean/utils/repeat.py | 39 +++++++++++++++++++------------------- pyproject.toml | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/port_ocean/utils/repeat.py b/port_ocean/utils/repeat.py index 1bda9e24d8..d762650299 100644 --- a/port_ocean/utils/repeat.py +++ b/port_ocean/utils/repeat.py @@ -61,26 +61,27 @@ async def wrapped() -> None: async def loop() -> None: nonlocal repetitions - if wait_first: - await asyncio.sleep(seconds) - while max_repetitions is None or repetitions < max_repetitions: - # count the repetition even if an exception is raised - repetitions += 1 - try: - if is_coroutine: - task = asyncio.create_task(func()) - signal_handler.register(lambda: task.cancel()) - ensure_future(task) - else: - await run_in_threadpool(func) - except Exception as exc: - formatted_exception = "".join( - format_exception(type(exc), exc, exc.__traceback__) - ) - logger.error(formatted_exception) - if raise_exceptions: - raise exc + # if wait_first: + # await asyncio.sleep(seconds) + # count the repetition even if an exception is raised + repetitions += 1 + try: + if is_coroutine: + task = asyncio.create_task(func()) + signal_handler.register(lambda: task.cancel()) + ensure_future(task) + else: + run_in_threadpool(func) + except Exception as exc: + formatted_exception = "".join( + format_exception(type(exc), exc, exc.__traceback__) + ) + logger.error(formatted_exception) + if raise_exceptions: + raise exc await asyncio.sleep(seconds) + if max_repetitions is None or repetitions < max_repetitions: + asyncio.get_event_loop().call_later(seconds, loop) ensure_future(loop()) diff --git a/pyproject.toml b/pyproject.toml index 5641228ec6..6cb4724a65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "port-ocean" -version = "0.12.2-dev12" +version = "0.12.2-dev13" description = "Port Ocean is a CLI tool for managing your Port projects." readme = "README.md" homepage = "https://app.getport.io"