This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Reimplemented coroutine.wrap, returning "nil, err" if the coroutine cannot | |
-- be resumed. | |
local co_wrap = function(func) | |
local co = coroutine.create(func) | |
ngx.log(ngx.DEBUG, "co created with status ", coroutine.status(co)) | |
return function(...) | |
if coroutine.status(co) == "suspended" then | |
return select(2, coroutine.resume(co, ...)) | |
else | |
return nil, "can't resume a " .. coroutine.status(co) .. " coroutine" |
NewerOlder