pynvim icon indicating copy to clipboard operation
pynvim copied to clipboard

Proper use of threads in plugins?

Open mcmire opened this issue 7 years ago • 2 comments

So I'm trying to use this plugin which interfaces with a server over TCP. The plugin works fine when sending data, but when receiving data it apparently causes the Python part of Neovim to abort, in a fashion very similar to (if not exactly like) #254. I believe that the line in this plugin that's causing this is here: https://github.com/timburgess/extempore.vim/blob/master/python/extempore3.py#L18. As you can see, a thread is kicked off every 0.3 seconds in the connect function to read from the socket. When I remove usage of the function where this thread business is happening then all is well.

I don't know Python very well, so I was wondering whether one of you would know off-hand why this isn't working or whether there's a better way to do this.

mcmire avatar Aug 01 '18 05:08 mcmire

As always, we need exact versions of python and nvim that you're using. I read here :

don't use asyncio before Python 3.5.3. There is a incredibly major bug with "asyncio.get_event_loop()" that makes it unusable for anything that involve mixing threads and loops

@bfredl I wonder if we should not use asyncio before python ~~3.6~~ 3.5.3

justinmk avatar Aug 10 '18 09:08 justinmk

I wonder if we should not use asyncio before python 3.6

@justinmk Except that it says "before 3.5.3". Distros should supply bugfix releases even if they are stuck on an older feature release. 3.5 is three years old, and even debian stable has it (3.5.3), it doesn't seem me an immodest requirement for doing fancy IO stuff.

bfredl avatar Aug 10 '18 18:08 bfredl