neovim / pynvim

Python client and plugin host for Nvim
http://pynvim.readthedocs.io/en/latest/
Apache License 2.0
1.51k stars 118 forks source link

Integration with asyncio #489

Open rr- opened 3 years ago

rr- commented 3 years ago

Related: #488

Let's say I already am running my own event loop (in my particular case it's quamash). How can I integrate this with nvim.run_loop()? As far as I see it ultimately calls pynvim.msgpack_rpc.event_loop.asyncio.AsyncioEventLoop._run:

    def _run(self):
        while self._queued_data:
            self._on_data(self._queued_data.popleft())
        self._loop.run_forever()

Needless to say calling this function is blocking my application, and calling it in a separate thread sprinkles lots of errors about cross-thread calls. Even if I tried to put everything in the same thread, it is unknown how to interact with self.nvim considering how self.nvim.run_loop is blocking.

justinmk commented 3 years ago

related https://github.com/neovim/pynvim/issues/352 https://github.com/neovim/pynvim/issues/342 https://github.com/neovim/pynvim/issues/324 https://github.com/neovim/pynvim/issues/323