From 3de55d688b2e7c71371a2f50c00962808bcfe629 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 13 Aug 2016 15:20:01 +0200 Subject: [PATCH] Improved timeouts --- main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 9d8d94bb..a54dab2c 100644 --- a/main.py +++ b/main.py @@ -22,8 +22,8 @@ file.close() # Every timeout seconds, update player status and check for levelups async def overwatch_level_up(timeout): while True: - # Wait for the timeout - await asyncio.sleep(timeout) + # Wait for the Discord client to be ready + await d_client.wait_until_ready() print("Checking for Overwatch updates.") # Update data for every player in list for player in db: @@ -44,12 +44,14 @@ async def overwatch_level_up(timeout): json.dump(db, f) f.close() print("Check for Overwatch completed.") + # Wait for the timeout + await asyncio.sleep(timeout) # Every timeout seconds, update player league and check for rank changes async def league_rank_change(timeout): while True: - # Wait for the timeout - await asyncio.sleep(timeout) + # Wait for the Discord client to be ready + await d_client.wait_until_ready() print("Checking for League of Legends updates.") # Update data for every player in list for player in db: @@ -82,6 +84,8 @@ async def league_rank_change(timeout): json.dump(db, f) f.close() print("Check for League of Legends completed.") + # Wait for the timeout + await asyncio.sleep(timeout) print("Added Overwatch to the queue.") loop.create_task(overwatch_level_up(900))