Skip to content

Commit 47d4b4f

Browse files
committed
fix YRoomFileAPI.stop()
1 parent 461be6a commit 47d4b4f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

jupyter_rtc_core/rooms/yroom_file_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ async def _process_scheduled_saves(self) -> None:
177177

178178
await self._save_jupyter_ydoc()
179179

180+
self.log.info(
181+
"Stopped `self._process_scheduled_save()` background task "
182+
f"for YRoom '{self.room_id}'."
183+
)
184+
180185

181186
async def _save_jupyter_ydoc(self):
182187
"""
@@ -215,6 +220,10 @@ async def stop(self) -> None:
215220
Gracefully stops the YRoomFileAPI, saving the content of
216221
`self.jupyter_ydoc` before exiting.
217222
"""
223+
# Stop the `self._process_scheduled_saves()` background task
224+
# immediately. This is safe since we save before stopping anyways.
225+
self._scheduled_saves.shutdown(immediate=True)
226+
218227
# Do nothing if content was not loaded first. This prevents overwriting
219228
# the existing file with an empty JupyterYDoc.
220229
if not (self._ydoc_content_loaded.is_set()):

0 commit comments

Comments
 (0)