Skip to content

Commit

Permalink
Fix cancellation of file save operation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Feb 28, 2024
1 parent b3e189e commit b956ba5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions jupyter_collaboration/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,11 @@ async def _maybe_save_document(self, saving_document: asyncio.Task | None) -> No
if saving_document is not None and not saving_document.done():
# the document is being saved, cancel that
saving_document.cancel()
await saving_document

# save after X seconds of inactivity
await asyncio.sleep(self._save_delay)

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

self.log.info("Saving the content from room %s", self._room_id)
await self._file.maybe_save_content(
{
Expand All @@ -253,6 +252,9 @@ async def _maybe_save_document(self, saving_document: asyncio.Task | None) -> No

self._emit(LogLevel.INFO, "save", "Content saved.")

except asyncio.CancelledError:
return

except OutOfBandChanges:
self.log.info("Out-of-band changes. Overwriting the content in room %s", self._room_id)
try:
Expand Down

0 comments on commit b956ba5

Please sign in to comment.