Skip to content

Commit

Permalink
Add comment about _maybe_save_document's cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Feb 29, 2024
1 parent b956ba5 commit f2f1bdb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jupyter_collaboration/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ async def _maybe_save_document(self, saving_document: asyncio.Task | None) -> No
# the document is being saved, cancel that
saving_document.cancel()

# all async code (i.e. await statements) must be part of this try/except block
# because this coroutine is run in a cancellable task and cancellation is handled here

try:
# save after X seconds of inactivity
await asyncio.sleep(self._save_delay)
Expand Down

0 comments on commit f2f1bdb

Please sign in to comment.