Skip to content

Commit 6c0b374

Browse files
committed
Fix 'dictionary changed size during iteration' error
Fixes #252, probably
1 parent 70d97bc commit 6c0b374

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

shiny/_app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ def _request_flush(self, session: Session) -> None:
310310
async def _flush_pending_sessions(self) -> None:
311311
# TODO: Until we have reactive domains, flush all sessions (because we
312312
# can't yet keep track of which ones need a flush)
313-
for _, session in self._sessions.items():
313+
# Use list() to create a copy, in case self._sessions mutates from under us,
314+
# which would cause a "dictionary changed size during iteration" RuntimeError
315+
for _, session in list(self._sessions.items()):
314316
await session._flush()
315317
# for id, session in self._sessions_needing_flush.items():
316318
# await session.flush()

0 commit comments

Comments
 (0)