From 9b155650517911ccae1d62c2e830bc78731170ca Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 7 Jul 2024 23:41:38 +0300 Subject: [PATCH] Config As An Argument --- async-bot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/async-bot.py b/async-bot.py index f83f192..2e2c3b4 100644 --- a/async-bot.py +++ b/async-bot.py @@ -263,6 +263,7 @@ class AsyncBotManager: await sio.emit("toggle_bit", {"index": index}) await asyncio.sleep(delay) self._active.add(bot_index) + break with suppress(BaseException): await sio.receive(0.1) print(f"Worker {bot_index} stopped: shutdown") @@ -278,8 +279,8 @@ class AsyncBotManager: await self._listener_task -async def amain() -> None: - with open("settings.json", "r") as fp: +async def amain(conf_path: str = "settings.json", *_) -> None: + with open(conf_path, "r") as fp: settings = load(fp) async with AsyncBotManager() as mgr: @@ -434,4 +435,5 @@ async def amain() -> None: if __name__ == "__main__": - asyncio.run(amain(), debug=True) + from sys import argv + asyncio.run(amain(argv[1:]), debug=True)