-
Notifications
You must be signed in to change notification settings - Fork 120
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: This event loop is already running #326
Comments
Tried the following patch: diff --git i/neovim/msgpack_rpc/event_loop/asyncio.py w/neovim/msgpack_rpc/event_loop/asyncio.py
index 656f552..5289957 100644
--- i/neovim/msgpack_rpc/event_loop/asyncio.py
+++ w/neovim/msgpack_rpc/event_loop/asyncio.py
@@ -106,12 +106,26 @@ def _start_reading(self):
def _send(self, data):
self._transport.write(data)
+ def is_running(self):
+ return self._loop.is_running() and not self._loop._stopping
+
def _run(self):
while self._queued_data:
self._on_data(self._queued_data.popleft())
diff --git i/neovim/msgpack_rpc/session.py w/neovim/msgpack_rpc/session.py
index b300f8d..1f93c6f 100644
--- i/neovim/msgpack_rpc/session.py
+++ w/neovim/msgpack_rpc/session.py
@@ -87,7 +87,7 @@ def request(self, method, *args, **kwargs):
raise ValueError("request got unsupported keyword argument(s): {}"
.format(', '.join(kwargs.keys())))
- if self._is_running:
+ if self._is_running and self.loop.is_running():
v = self._yielding_request(method, args)
else:
v = self._blocking_request(method, args) But that does not fix it. I guess it might miss events, and I've also seen this then:
|
Hmm, it looks like nvim methods are invoked directly from a separate thread, that is definietly not safe. |
Related? #324 / tweekmonster/deoplete-clang2#30 |
@bfredl |
With deoplete-jedi it currently looks like this:
|
I don't think I can. Deoplete doesn't use threading anymore. |
deoplete-jedi does though. It basically can be triggered by using deoplete's logger from the thread. deoplete's logger has a filter to call into Neovim via
|
I wonder if deoplete-jedi should also switch to using asyncio instead of threads, but that might not be trivial. /cc @Shougo |
As for deoplete-jedi I will change it to get the exceptions from the threads into the caller, and then logging should happen from there. |
Hm. If possible. |
Can we close this? Can someone suggest a small documentation update? |
What would be a documentation update? |
This is what I've done for deoplete-jedi: deoplete-plugins/deoplete-jedi#178 - it stores exceptions in the threads, and collects them for non-alive threads then. |
I am seeing a
RuntimeError: This event loop is already running
when using`log.exception from deoplete-jedi's server.
This appears to be caused by DeopleteLogFilter.filter using
self.vim.call('deoplete#util#print_error', record.getMessage(), record.name)
.Full traceback (the code in deoplete-jedi (from the first exception) is new ):
Another instance:
Code in cpython: https://github.com/python/cpython/blob/20d68dfcc07bd389ce2ea7b0773c44d97ebeb68d/Lib/asyncio/base_events.py#L507-L508
It appears to be a race, since
is_running()
only looks at the thread_id, andnot
_stopping
(which is whatstop()
sets).Events:
So neovim stops the loop ("stopping"), but then calls
self._loop.run_forever
again, since the internalis_running
is false, butrun_forever
will then raise the RuntimeError.I've tried using
self.loop._loop.is_running
directly/alone, but then the greenlet parent might be None:The text was updated successfully, but these errors were encountered: