gpt4 book ai didi

nginx - Luasocket + nginx 错误 - lua 入口线程中止 : runtime error: attempt to yield across C-call boundary

转载 作者:行者123 更新时间:2023-12-03 10:43:12 26 4
gpt4 key购买 nike

当我使用以下脚本时:

local smtp = require("socket.smtp")
local from = "from@host"
local rcpt = "rcpt@host"
local msg = {
headers = {
to = rcpt,
subject = "Hi"
},
body = "Hello"
}
smtp.send{from = from,rcpt = rcpt,source = smtp.message(msg)}

我收到一条错误消息: lua entry thread aborted: runtime error: attempt to yield across C-call boundary .

我正在使用最新的 luasocket安装自 luarocks使用 LuaJIT 2.1 编译的使用 nginx 的 Lua 5.1。是什么导致了此错误消息,我该如何解决?

最佳答案

这是由 LuaJIT 和 socket.smtp 的组合使用引起的,它启动了一个协程。来自 https://github.com/openresty/lua-nginx-module/issues/376 :

@AterCattus This is a known limitation in LuaJIT (and the standard Lua 5.1 interpreter) that the require() builtin is currently implemented as a C builtin across which you cannot initiate a yield.



看起来最好的解决方法可能是使用 require.lua 的这个实现: https://github.com/pygy/require.lua .它是用纯 Lua 而不是 C 编写的,以解决 LuaJIT 的这个问题。

关于nginx - Luasocket + nginx 错误 - lua 入口线程中止 : runtime error: attempt to yield across C-call boundary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30111808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com