-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: Already mutably borrowed #79
Comments
I get a similar but slightly different error if I try it without WebsocketServer. import pycrdt
def handle_changes(ydoc):
print('handle_changes')
print(ydoc['workspace']['env'])
print('never reached')
ydoc = pycrdt.Doc()
ydoc['workspace'] = ws = pycrdt.Map()
ydoc['workspace']['env'] = 'unset'
ydoc.observe(lambda event: handle_changes(ydoc))
print('watch out')
ydoc['workspace']['env'] = 'good' The output:
|
It seems to me that you want to observe changes on the import pycrdt
def handle_changes(event):
print(event.target['env'])
ydoc = pycrdt.Doc()
ydoc['workspace'] = ws = pycrdt.Map()
ws['env'] = 'unset'
ws.observe(handle_changes)
ws['env'] = 'good' |
Wow, thanks! That works great! When I do the same in my websocket setup, the function registered with |
I construct the empty YDoc with If I call But if the same update comes from the frontend and Maybe something happens to the YDoc before the update arrives? I'll try deleting everything that touches YDoc. Or it's some threading/async thing, where
Anyway, I'll keep digging. I must be close! |
I've got something. I think it's destructors deleting subscriptions. import pycrdt
def handle_changes(event):
print(event.target['env'])
ydoc = pycrdt.Doc()
ydoc['workspace'] = ws = pycrdt.Map()
ws['env'] = 'unset'
ws.observe(handle_changes)
del ws
ydoc['workspace']['env'] = 'good' It's the same as your example except for the last two lines. If I find this behavior surprising, because I didn't think of Anyway, thanks a million for PyCRDT! My application will be so collaborative! |
The thing is that |
Description
I have a
pycrdt.Doc
that I make available to clients through apycrdt_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: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.The text was updated successfully, but these errors were encountered: