Skip to content

Commit

Permalink
switched while true to call later
Browse files Browse the repository at this point in the history
  • Loading branch information
yairsimantov20 committed Oct 16, 2024
1 parent 625cb2b commit bd093b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
39 changes: 20 additions & 19 deletions port_ocean/utils/repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit bd093b2

Please sign in to comment.