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():