From 221902508f3e0ecd43eded77413b683e3818a254 Mon Sep 17 00:00:00 2001 From: Ivaylo Novakov Date: Tue, 18 Aug 2020 18:25:54 +0300 Subject: [PATCH] Give the client 10 seconds to properly exits and if it fails to do so `exit` the hard way. --- setup-scripts/funds-checker.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setup-scripts/funds-checker.py b/setup-scripts/funds-checker.py index 4608352d..2f840538 100755 --- a/setup-scripts/funds-checker.py +++ b/setup-scripts/funds-checker.py @@ -5,15 +5,21 @@ health-checker runs simple health checks on a portal node using the siad API and dispatches messages to a Discord channel. """ -import discord, traceback +import discord, traceback, asyncio from bot_utils import setup, send_msg, siad, sc_precision bot_token = setup() client = discord.Client() +async def exit_after(delay): + await asyncio.sleep(delay) + exit(0) + + @client.event async def on_ready(): await run_checks() + asyncio.create_task(exit_after(10)) await client.close()