pcall execute_module, #1331

This commit is contained in:
Cloud Wu
2021-01-25 20:31:04 +08:00
parent 41cc6d226c
commit 4534fb5269

View File

@@ -62,19 +62,24 @@ do
context[co] = init_list
-- We should call modfunc in lua, because modfunc may yield by calling M.require recursive.
local m = modfunc(name, filename)
local function execute_module()
local m = modfunc(name, filename)
for _, f in ipairs(init_list) do
f()
for _, f in ipairs(init_list) do
f()
end
if m == nil then
m = true
end
loaded[name] = m
end
local ok, err = xpcall(execute_module, debug.traceback)
context[co] = old_init_list
if m == nil then
m = true
end
package.loaded[name] = m
local waiting = #loading_queue
if waiting > 0 then
local skynet = require "skynet"
@@ -84,7 +89,11 @@ do
end
loading[name] = nil
return m
if ok then
return loaded[name]
else
error(err)
end
end
end