Skip to content

Commit 131e41a

Browse files
author
Jialin Zhang
committed
change yroom class attribute to instance attribute
1 parent 1cd727f commit 131e41a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

pycrdt_websocket/yroom.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from functools import partial
55
from inspect import isawaitable
66
from logging import Logger, getLogger
7-
from typing import Awaitable, Callable
7+
from typing import Awaitable, Callable, Tuple
88

99
from anyio import (
1010
TASK_STATUS_IGNORED,
@@ -37,12 +37,11 @@ class YRoom:
3737
_on_message: Callable[[bytes], Awaitable[bool] | bool] | None
3838
_update_send_stream: MemoryObjectSendStream
3939
_update_receive_stream: MemoryObjectReceiveStream
40-
_task_group: TaskGroup | None = None
41-
_started: Event | None = None
40+
_task_group: TaskGroup | None
41+
_started: Event | None
4242
_stopped: Event
43-
__start_lock: Lock | None = None
44-
_subscription: Subscription | None = None
45-
43+
__start_lock: Lock | None
44+
_subscription: Subscription | None
4645
def __init__(
4746
self,
4847
ready: bool = True,
@@ -82,6 +81,13 @@ def __init__(
8281
self._on_message = None
8382
self.exception_handler = exception_handler
8483
self._stopped = Event()
84+
self._update_send_stream, self._update_receive_stream = create_memory_object_stream(
85+
max_buffer_size=65536
86+
)
87+
self._task_group = None
88+
self._started = None
89+
self.__start_lock = None
90+
self._subscription= None
8591

8692
@property
8793
def _start_lock(self) -> Lock:
@@ -230,6 +236,7 @@ async def stop(self) -> None:
230236
self._stopped.set()
231237
self._task_group.cancel_scope.cancel()
232238
self._task_group = None
239+
await self.ystore.stop()
233240
if self._subscription is not None:
234241
self.ydoc.unobserve(self._subscription)
235242

0 commit comments

Comments
 (0)