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
Run the server using a websocket, e.g. poetry run jedi-language-server --ws --verbose --log-file .logs.txt
Using any client (or use the monaco-languageclient example, instructions to which can be found here, get the client to emit one of textDocument/didOpen, textDocument/didChange, textDocument/didSave, textDocument/didClose or textDocument/hover.
The server should spit out many errors that are all RuntimeError: There is no current event loop in thread X
When I forked this project and ran it locally, using the monaco-languageclient react client example as a client, I kept getting crashes when the diagnostic actions (e.g. textDocument/didOpen, textDocument/didChange, textDocument/didSave, textDocument/didClose and textDocument/hover) were being emitted. The error I was getting was: RuntimeError: There is no current event loop in thread X
After a few hours of debugging, I realized that it was coming from this file, where the Diagnostic methods are being run in a thread using Timer. This leads to that thread not having an event loop to send things via websocket.
I fixed this by replacing lines 68 - 80 with:
async def run() -> None:
with lock:
del timers[key]
return func(*args, **kwargs)
with lock:
old_timer = timers.get(key)
if old_timer:
old_timer.cancel()
timer = threading.Timer(interval_s, asyncio.run_coroutine_threadsafe, args=(run(), asyncio.get_running_loop()))
timers[key] = timer
timer.start()
This ensures that the thread has an event loop to use, and changing it to this made the diagnostic actions work again.
The text was updated successfully, but these errors were encountered:
To reproduce
poetry run jedi-language-server --ws --verbose --log-file .logs.txt
RuntimeError: There is no current event loop in thread X
When I forked this project and ran it locally, using the monaco-languageclient react client example as a client, I kept getting crashes when the diagnostic actions (e.g. textDocument/didOpen, textDocument/didChange, textDocument/didSave, textDocument/didClose and textDocument/hover) were being emitted. The error I was getting was:
RuntimeError: There is no current event loop in thread X
After a few hours of debugging, I realized that it was coming from this file, where the Diagnostic methods are being run in a thread using Timer. This leads to that thread not having an event loop to send things via websocket.
I fixed this by replacing lines 68 - 80 with:
This ensures that the thread has an event loop to use, and changing it to this made the diagnostic actions work again.
The text was updated successfully, but these errors were encountered: