From 9962cd3d4eef880cd9239af203c8d201ddd89060 Mon Sep 17 00:00:00 2001 From: tursom Date: Fri, 1 Mar 2024 15:10:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=85=E5=8A=A9=E7=BA=BF=E7=A8=8B=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E6=94=B9=E4=B8=BA=E5=AE=88=E6=8A=A4=E7=BA=BF=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sample.py b/sample.py index f5fd9d1..ebc22a7 100644 --- a/sample.py +++ b/sample.py @@ -52,12 +52,13 @@ async def main(): raise e # run subscribe_redis on new thread - threading.Thread(target=subscribe_redis).start() + threading.Thread(target=subscribe_redis, daemon=True).start() while True: await asyncio.gather(*( clients[room_id].join() for room_id in clients )) + await asyncio.sleep(1) finally: for room_id in clients: await clients[room_id].stop_and_close() @@ -67,7 +68,10 @@ async def main(): def flush_files(): for room_id in log_files: log_files[room_id].flush() - threading.Timer(1, flush_files).start() + + timer = threading.Timer(1, flush_files) + timer.daemon = True + timer.start() def subscribe_redis():