-
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
Cannot execute a vim command from a new asyncio task #342
Comments
I forgot to type a description before creating the issue, so I went back and edited the description after creating it. |
Just tried it, and it works for me using Python 3.6.6 and pynvim master. Also |
However, only the first command gets run. With the following only :py3 async def foo(): vim.command('echom 1'); vim.command('echom 2')
:py3 import asyncio; asyncio.ensure_future(foo()) |
Yeah, your issue after all.. - so confirming ;) |
Using |
Is that something that |
nvim-managed greenlets and asyncio coroutines are like water and oil, they are incompatible event/async primitives that simply don't mix: any attempt to "seamlessly" integrate them might fail in the first request stack/event handing situation that wasn't explicitly considered. What we could add is (1) a greenlet-callable function, that runs an asyncio coro/future until completion and then resumes the greenlet and (2) an awaitable function that suspends a coroutine and runs a closure as a greenlet until it completes and then resumes the coroutine. Though this will more or less be callback hell and thus have none of the benefits of either the stackful greenlet approach or the explicitly yieldable approach of asyncio coroutines. Rather what I would imagine useful is to reimplement the python client using only asyncio and native coroutines and no greenlets, I suspect that will be a lot simpler than the exisiting multi-layer client: it will more or less be a library providing a |
I would really love to have all these strange event loops dropped and replaced with asyncio/trollius, though wouldn't there be a backwards compatibility problem? |
Yes. It would need be a separate project from this. I wouldn't even think "fork", rather new codebase which can happen to borrow code from this where it makes sense. Starting from scratch with no regards of vim compatibility (which necessitates a sync-like interface backed by greenlets or similar) would give a lot more freedom for both simplicity and expressivity. For instance |
I need the fix for denite.nvim split processes feature. |
To reproduce: Start Neovim with NVIM_PYTHON_LOG_FILE set, and run these commands:
Then look in the python log file (
_script
suffix) and see:The text was updated successfully, but these errors were encountered: