Skip to content

Commit 838926f

Browse files
committed
safe await cancelled task
1 parent d771e3e commit 838926f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

reflex/istate/manager/redis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ async def lease_breaker():
657657
# There's already a lease break task, so cancel it to clear it out.
658658
existing_task.cancel()
659659
if existing_task is not None:
660-
await existing_task
660+
with contextlib.suppress(asyncio.CancelledError):
661+
await existing_task
661662

662663
# Now we might need to create a new lock.
663664
if (state_lock := self._cached_states_locks.get(client_token)) is None:
@@ -783,7 +784,7 @@ async def _lock_updates_forever(self) -> None:
783784
try:
784785
await self._subscribe_lock_updates(redis_db)
785786
except asyncio.CancelledError: # noqa: PERF203
786-
break
787+
raise
787788
except Exception as e:
788789
console.error(f"StateManagerRedis lock update task error: {e}")
789790

0 commit comments

Comments
 (0)