Skip to content

Commit 2691f58

Browse files
committed
update docstrings
1 parent 527001c commit 2691f58

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

jupyter_server_documents/rooms/yroom_manager.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
class YRoomManager():
1414
"""
1515
A singleton that manages all `YRoom` instances in the server extension. This
16-
automatically deletes empty `YRoom`s with no connected clients or active
17-
kernel every 10 seconds.
16+
automatically deletes `YRoom` instances if they have had no connected
17+
clients or active kernel for >10 seconds.
1818
1919
Because rooms may be deleted due to inactivity, consumers should only store
2020
a reference to the room ID and call `get_room(room_id)` each time a
21-
reference to the room is needed. This method is cheap as long as the room
22-
still exists.
21+
reference to the room is needed. See `get_room()` for more details.
2322
"""
2423

2524
_rooms_by_id: dict[str, YRoom]
@@ -79,12 +78,17 @@ def fileid_manager(self) -> BaseFileIdManager:
7978

8079
def get_room(self, room_id: str) -> YRoom | None:
8180
"""
82-
Retrieves a YRoom given a room ID. If the YRoom does not exist, this
83-
method will initialize a new YRoom.
81+
Returns the `YRoom` instance for a given room ID. If the instance does
82+
not exist, this method will initialize one and return it. Otherwise,
83+
this method returns the instance from its cache, ensuring that this
84+
method is fast in almost all cases.
8485
85-
This method ensures that the returned room will be alive for >10
86+
Consumers should always call this method each time a reference to the
87+
`YRoom` is needed, since rooms may be deleted due to inactivity.
88+
89+
This method also ensures that the returned room will be alive for >10
8690
seconds. This prevents the room from being deleted shortly after the
87-
consumer receives it via this method, even if it is inactive.
91+
consumer receives it via this method, even if it was inactive.
8892
"""
8993
# First, ensure this room stays open for >10 seconds by removing it from
9094
# the inactive set of rooms if it is present.

0 commit comments

Comments
 (0)