From 1f3be6340ca65cb5c775911ad300f79fab3a95ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Brand=C3=A9ho?= Date: Mon, 7 Oct 2024 09:27:36 -0700 Subject: [PATCH] catch CancelledError in lifespan hack for windows (#4083) --- reflex/utils/compat.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/reflex/utils/compat.py b/reflex/utils/compat.py index 27c4753db..b6d198fd4 100644 --- a/reflex/utils/compat.py +++ b/reflex/utils/compat.py @@ -19,10 +19,13 @@ async def windows_hot_reload_lifespan_hack(): import asyncio import sys - while True: - sys.stderr.write("\0") - sys.stderr.flush() - await asyncio.sleep(0.5) + try: + while True: + sys.stderr.write("\0") + sys.stderr.flush() + await asyncio.sleep(0.5) + except asyncio.CancelledError: + pass @contextlib.contextmanager