From e9e5c8515243c27956b350a525e54bdee4f85074 Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Mon, 14 Oct 2024 10:05:12 +0200 Subject: [PATCH 1/4] Start the server awareness --- pycrdt_websocket/yroom.py | 1 + pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pycrdt_websocket/yroom.py b/pycrdt_websocket/yroom.py index ba4b654..f1de878 100644 --- a/pycrdt_websocket/yroom.py +++ b/pycrdt_websocket/yroom.py @@ -231,6 +231,7 @@ async def start( self._task_group.start_soon(self._stopped.wait) self._task_group.start_soon(self._watch_ready) self._task_group.start_soon(self._broadcast_updates) + self._task_group.start_soon(self.awareness.start) return except Exception as exception: self._handle_exception(exception) diff --git a/pyproject.toml b/pyproject.toml index b9685a0..02afbcf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ dependencies = [ "anyio >=3.6.2,<5", "sqlite-anyio >=0.2.3,<0.3.0", - "pycrdt >=0.10.1,<0.11.0", + "pycrdt >=0.10.3,<0.11.0", ] [project.optional-dependencies] From 01bf3f3d9f4cb626e926f661eda59b0b178145a0 Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Mon, 14 Oct 2024 21:29:59 +0200 Subject: [PATCH 2/4] Stop the awareness --- pycrdt_websocket/yroom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pycrdt_websocket/yroom.py b/pycrdt_websocket/yroom.py index f1de878..f36eb89 100644 --- a/pycrdt_websocket/yroom.py +++ b/pycrdt_websocket/yroom.py @@ -241,6 +241,7 @@ async def stop(self) -> None: if self._task_group is None: raise RuntimeError("YRoom not running") self._stopped.set() + self.awareness.stop() self._task_group.cancel_scope.cancel() self._task_group = None if self._subscription is not None: From 0d22fce1b944305b0b7e0392933e89ae421853b7 Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Mon, 14 Oct 2024 22:12:36 +0200 Subject: [PATCH 3/4] Apply suggestions from review Co-authored-by: David Brochart <4711805+davidbrochart@users.noreply.github.com> --- pycrdt_websocket/yroom.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pycrdt_websocket/yroom.py b/pycrdt_websocket/yroom.py index f36eb89..c913ae8 100644 --- a/pycrdt_websocket/yroom.py +++ b/pycrdt_websocket/yroom.py @@ -213,6 +213,7 @@ async def start( self._task_group.start_soon(self._stopped.wait) self._task_group.start_soon(self._watch_ready) self._task_group.start_soon(self._broadcast_updates) + self._task_group.start_soon(self.awareness.start) return async with self._start_lock: @@ -241,7 +242,7 @@ async def stop(self) -> None: if self._task_group is None: raise RuntimeError("YRoom not running") self._stopped.set() - self.awareness.stop() + await self.awareness.stop() self._task_group.cancel_scope.cancel() self._task_group = None if self._subscription is not None: From 1e9d98a45751efc507380a7a8f5ef560e89ddc9a Mon Sep 17 00:00:00 2001 From: David Brochart Date: Mon, 14 Oct 2024 22:26:49 +0200 Subject: [PATCH 4/4] Stop awareness on error --- pycrdt_websocket/yroom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pycrdt_websocket/yroom.py b/pycrdt_websocket/yroom.py index c913ae8..6a9c2ec 100644 --- a/pycrdt_websocket/yroom.py +++ b/pycrdt_websocket/yroom.py @@ -235,6 +235,7 @@ async def start( self._task_group.start_soon(self.awareness.start) return except Exception as exception: + await self.awareness.stop() self._handle_exception(exception) async def stop(self) -> None: