plenary.nvim icon indicating copy to clipboard operation
plenary.nvim copied to clipboard

C-call boundary error in async run

Open koopa1338 opened this issue 3 years ago • 3 comments

I am getting errors while using the oneshot channel like in the readme. Here a minimal example I tested:

Test = function()
  local async = require'plenary.async'
  local tx, rx = async.control.channel.oneshot()

  a.run(function()
      tx("sending...")
  end)

  local result = rx()
  print(result)
end

I get the following error:

E5108: Error executing lua /home/koopa/.config/nvim/lua/utils.lua:81: attempt to yield across C-call boundary
stack traceback:
	[C]: in function 'rx'
	/home/koopa/.config/nvim/lua/utils.lua:81: in function 'Test'
	[string ":lua"]:1: in main chunk

nvim version:

NVIM v0.7.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Features: +acl +iconv +tui

koopa1338 avatar Aug 30 '22 00:08 koopa1338

Not a maintainer, just a user. All of the examples are written to be wrapped in asyncio.run. You can use asyncio.run as in this example to run an async function without awaiting it in the current async function.

rcarriga avatar Sep 05 '22 20:09 rcarriga

@rcarriga A quick search for ´asyncio` in the repo didn't return any results. Can you give me a simple example how this would look like?

koopa1338 avatar Sep 08 '22 20:09 koopa1338

Ah sorry had my Python hat on :sweat_smile: Meant just async as in require("plenary.async").

rcarriga avatar Sep 09 '22 06:09 rcarriga