Skip to content

Commit

Permalink
Use time.monotonic
Browse files Browse the repository at this point in the history
  • Loading branch information
filipre committed Jul 16, 2023
1 parent ad1149c commit 954fff1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ version = "0.7.0"
[tool.poetry.dependencies]
APScheduler = "^3.9.1"
aiohttp = "^3.8.1"
python = "^3.11"
python = "^3.9"
redis = "^4.1.4"
websockets = "^10.2"

Expand Down
6 changes: 3 additions & 3 deletions signalbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async def _rerun_on_exception(cls, coro, *args, **kwargs):

next_sleep = init_sleep
while True:
start_t = int(time.time()) # seconds
start_t = int(time.monotonic()) # seconds

try:
await coro(*args, **kwargs)
Expand All @@ -240,7 +240,7 @@ async def _rerun_on_exception(cls, coro, *args, **kwargs):
except Exception:
traceback.print_exc()

end_t = int(time.time()) # seconds
end_t = int(time.monotonic()) # seconds

if end_t - start_t < reset:
sleep_t = next_sleep
Expand All @@ -250,7 +250,7 @@ async def _rerun_on_exception(cls, coro, *args, **kwargs):
sleep_t = next_sleep

logging.warning(f"Restarting coroutine in {sleep_t} seconds")
await asyncio.sleep(sleep_t) # TODO
await asyncio.sleep(sleep_t)

async def _produce_consume_messages(self, producers=1, consumers=3) -> None:
for n in range(1, producers + 1):
Expand Down

0 comments on commit 954fff1

Please sign in to comment.