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
Due to web socket objects aquiring an exclusive lock, this piece of code currently does not work:
localtask=require("@lune/task")
localnet=require("@lune/net")
localsocket=net.socket("wss://...")
task.spawn(function()
whiletruedolocalmessage=socket.next()
-- ...endend)
task.defer(function()
print("0")
-- This will yield indefinitely since `socket.next` completely locks the socketsocket.send(...)
print("1")
end)
I see two possible solutions here:
Split the websocket into send & receive parts, lock them separately when their methods are called
Handle receiving/sending of messages internally, not directly exposing it to lua. This would mean wrapping the websocket in some kind of message queue so that when we call next from multiple lua threads, and receive a message, all waiting lua threads will get the same message
The second solution seems more robust to me but may also require us to integrate with the async scheduler in some capacity
The text was updated successfully, but these errors were encountered:
Due to web socket objects aquiring an exclusive lock, this piece of code currently does not work:
I see two possible solutions here:
next
from multiple lua threads, and receive a message, all waiting lua threads will get the same messageThe second solution seems more robust to me but may also require us to integrate with the async scheduler in some capacity
The text was updated successfully, but these errors were encountered: