Skip to content

Commit 8f70b9f

Browse files
author
Jialin Zhang
committed
change yroom class attribute to instance attribute
1 parent aa48250 commit 8f70b9f

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

pycrdt_websocket/yroom.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,6 @@
3030

3131

3232
class YRoom:
33-
clients: list
34-
ydoc: Doc
35-
ystore: BaseYStore | None
36-
ready_event: Event
37-
_on_message: Callable[[bytes], Awaitable[bool] | bool] | None
38-
_update_send_stream: MemoryObjectSendStream
39-
_update_receive_stream: MemoryObjectReceiveStream
40-
_task_group: TaskGroup | None = None
41-
_started: Event | None = None
42-
_stopped: Event
43-
__start_lock: Lock | None = None
44-
_subscription: Subscription | None = None
45-
4633
def __init__(
4734
self,
4835
ready: bool = True,
@@ -72,16 +59,23 @@ def __init__(
7259
returns True if the exception was handled.
7360
log: An optional logger.
7461
"""
75-
self.ydoc = Doc()
62+
self.ydoc : Doc = Doc()
7663
self.awareness = Awareness(self.ydoc)
77-
self.ready_event = Event()
64+
self.ready_event : Event = Event()
7865
self.ready = ready
79-
self.ystore = ystore
66+
self.ystore : BaseYStore | None = ystore
8067
self.log = log or getLogger(__name__)
81-
self.clients = []
82-
self._on_message = None
68+
self.clients : list = []
69+
self._on_message : Callable[[bytes], Awaitable[bool] | bool] | None = None
8370
self.exception_handler = exception_handler
84-
self._stopped = Event()
71+
self._stopped : Event = Event()
72+
self._update_send_stream, self._update_receive_stream = create_memory_object_stream(
73+
max_buffer_size=0
74+
)
75+
self._task_group : TaskGroup | None = None
76+
self._started: Event | None = None
77+
self.__start_lock: Lock | None = None
78+
self._subscription: Subscription | None = None
8579

8680
@property
8781
def _start_lock(self) -> Lock:

0 commit comments

Comments
 (0)