Skip to content

RuntimeError: Already mutably borrowed #79

@darabos

Description

@darabos

Description

I have a pycrdt.Doc that I make available to clients through a pycrdt_websocket.WebsocketServer. It's contained in a YRoom.

I want to react to changes in this doc on the server side too. I use observe() to be notified of the changes. Upon a change I want to access the contents of the Doc. But this fails:

  File "python3.12/site-packages/pycrdt/_doc.py", line 198, in __getitem__
    return self._roots[key]
           ^^^^^^^^^^^
  File "python3.12/site-packages/pycrdt/_doc.py", line 246, in _roots
    with self.transaction() as txn:
  File "python3.12/site-packages/pycrdt/_transaction.py", line 61, in __enter__
    self._txn = self._doc._doc.create_transaction()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Already mutably borrowed

What am I doing wrong? Does the YRoom have exclusive access to the Doc?

Reproduce

I can try to make an isolated repro if necessary.

Expected behavior

I was hoping I could access the data in the Doc from the observe() event handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions