Skip to content

Commit

Permalink
Start the server awareness (#78)
Browse files Browse the repository at this point in the history
* Start the server awareness

* Stop the awareness

* Apply suggestions from review

Co-authored-by: David Brochart <[email protected]>

* Stop awareness on error

---------

Co-authored-by: David Brochart <[email protected]>
Co-authored-by: David Brochart <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2024
1 parent c7e3955 commit b43acfd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pycrdt_websocket/yroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -231,15 +232,18 @@ 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:
await self.awareness.stop()
self._handle_exception(exception)

async def stop(self) -> None:
"""Stop the room."""
if self._task_group is None:
raise RuntimeError("YRoom not running")
self._stopped.set()
await self.awareness.stop()
self._task_group.cancel_scope.cancel()
self._task_group = None
if self._subscription is not None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit b43acfd

Please sign in to comment.