File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
projects/jupyter-server-ydoc/jupyter_server_ydoc Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ async def open(self, room_id):
259259 )
260260
261261 # Clean up the room and delete the file loader
262- if len (self .room .clients ) == 0 or self .room .clients == [ self ] :
262+ if len (self .room .clients ) == 0 or self .room .clients == { self } :
263263 self ._message_queue .put_nowait (b"" )
264264 self ._cleanup_delay = 0
265265 await self ._clean_room ()
@@ -321,7 +321,7 @@ def on_close(self) -> None:
321321 """
322322 # stop serving this client
323323 self ._message_queue .put_nowait (b"" )
324- if isinstance (self .room , DocumentRoom ) and self .room .clients == [ self ] :
324+ if isinstance (self .room , DocumentRoom ) and self .room .clients == { self } :
325325 # no client in this room after we disconnect
326326 # keep the document for a while in case someone reconnects
327327 self .log .info ("Cleaning room: %s" , self ._room_id )
Original file line number Diff line number Diff line change @@ -203,13 +203,28 @@ async def _watch_file(self) -> None:
203203 if self ._poll_interval is None :
204204 return
205205
206+ consecutive_error_logs = 0
207+ max_consecutive_logs = 3
208+ suppression_logged = False
209+
206210 while True :
207211 try :
208212 await asyncio .sleep (self ._poll_interval )
209213 try :
210214 await self .maybe_notify ()
215+ consecutive_error_logs = 0
216+ suppression_logged = False
211217 except Exception as e :
212- self ._log .error (f"Error watching file: { self .path } \n { e !r} " , exc_info = e )
218+ if consecutive_error_logs < max_consecutive_logs :
219+ self ._log .error (f"Error watching file: { self .path } \n { e !r} " , exc_info = e )
220+ consecutive_error_logs += 1
221+ elif not suppression_logged :
222+ self ._log .warning (
223+ "Too many errors while watching %s — suppressing further logs." ,
224+ self .path ,
225+ )
226+ suppression_logged = True
227+
213228 except asyncio .CancelledError :
214229 break
215230
You can’t perform that action at this time.
0 commit comments