Browse Source

catch CancelledError in lifespan hack for windows (#4083)

Thomas Brandého 7 months ago
parent
commit
c05d0bca55
1 changed files with 7 additions and 4 deletions
  1. 7 4
      reflex/utils/compat.py

+ 7 - 4
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