You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
seems to be similar to #69
I have three maps like a kanban : todos, doing, done and i want a worker to be able to "move" a task from "todos" to "doing" but i've got an "already borrowed" error and i don't know how to deal with it
here is my code
import asyncio
import y_py as Y
from websockets import connect
from ypy_websocket import WebsocketProvider
async def client():
ydoc = Y.YDoc()
async with (
connect("ws://localhost:1234/my-roomname") as websocket,
WebsocketProvider(ydoc, websocket),
):
def callback(e):
print("\n-----------")
print("TODOS",todos)
print("DOING",doing)
print("DONE",done)
#print("\nKEYS",todos.keys())
#print("\nEVENTS",e.keys)
for id , task in todos.items():
print("------1 todo",id, "->", task)
try:
ydoc.transact(lambda txn: todos.pop(txn, id))
ydoc.transact(lambda txn: doing.set(txn, id, task))
except Exception as e:
print("ERROR", e)
todos = ydoc.get_map("todos")
doing = ydoc.get_map("doing")
done = ydoc.get_map("done")
todos.observe(callback)
doing.observe(callback)
done.observe(callback)
await asyncio.Future() # run forever
asyncio.run(client())
The text was updated successfully, but these errors were encountered:
scenaristeur
changed the title
already borrowed trying to update in a callback
ERROR message "already borrowed" when trying to update in a callback
Mar 24, 2024
scenaristeur
changed the title
ERROR message "already borrowed" when trying to update in a callback
ERROR message "already borrowed" when trying to update a map in a callback
Mar 24, 2024
seems to be similar to #69
I have three maps like a kanban : todos, doing, done and i want a worker to be able to "move" a task from "todos" to "doing" but i've got an "already borrowed" error and i don't know how to deal with it
here is my code
and the log :
The text was updated successfully, but these errors were encountered: