Skip to content

Synchronous call initiated through a response of an async call drops the results of the sync call. #566

Open
@Badhi

Description

@Badhi

I have created a sample plugin that recreates my issue below.

  • lua in test_plugin/lua/test_plugin/init.lua
M = {}

function M.run()
    vim.fn.Start(1)
    vim.fn.Start(2)
end

function M.update(data)
    print(vim.fn.GetData(data))
end

return M
  • python in test_plugin/rplugin/python3/test_plugin.py
import pynvim
import logging

@pynvim.plugin
class TestPlugin(object):
    def __init__(self, nvim : pynvim.Nvim):
        logging.basicConfig(filename = 'test.log', level='DEBUG')
        self.nvim = nvim

    @pynvim.function('Start', sync=False)
    def start(self, args):
        logging.debug('start called')
        d = args[0]
        self.nvim.exec_lua("require'test_plugin'.update(...)", d, async_ = True)

    @pynvim.function('GetData', sync = True)
    def getData(self, args):
        logging.debug('getdata called')
        d = args[0]
        return d

Here, when i call lua require'test_plugin'.run() I could see both start and getData functions in python getting called twice but the return values of the getData function is never captured by the neovim

Also, if I remove one of the vim.fn.Start calls in run() function, everything works fine.

Appreciate if someone can help me with this and check if I'm not using the pynvim apis incorrectly

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions