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):
259
259
)
260
260
261
261
# 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 } :
263
263
self ._message_queue .put_nowait (b"" )
264
264
self ._cleanup_delay = 0
265
265
await self ._clean_room ()
@@ -321,7 +321,7 @@ def on_close(self) -> None:
321
321
"""
322
322
# stop serving this client
323
323
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 } :
325
325
# no client in this room after we disconnect
326
326
# keep the document for a while in case someone reconnects
327
327
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:
203
203
if self ._poll_interval is None :
204
204
return
205
205
206
+ consecutive_error_logs = 0
207
+ max_consecutive_logs = 3
208
+ suppression_logged = False
209
+
206
210
while True :
207
211
try :
208
212
await asyncio .sleep (self ._poll_interval )
209
213
try :
210
214
await self .maybe_notify ()
215
+ consecutive_error_logs = 0
216
+ suppression_logged = False
211
217
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
+
213
228
except asyncio .CancelledError :
214
229
break
215
230
You can’t perform that action at this time.
0 commit comments