lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Have you checkd coxpcall.lua (from Xavante) to replace your pcalls?
Xavante uses this module to avoid that kind of errors so that may help
you.
http://luaforge.net/projects/xavante/

André

On 5/10/07, jm_list@cameraid.com <jm_list@cameraid.com> wrote:
> The limitations are not for the language, but for the fact that C does
> not offer a way to do coroutines itself.
> Quick explanation as to why you may run into limitations:

I wasn't trying to put any of my C calls in between the resume and the yield.

It seems the culprit in my case is that "request" is wrapped inside a
"socket.protect", which makes it into a pcall, which of course can't be
done inside a coroutine.

Compare:

request = socket.protect(function(reqt, body)
    if base.type(reqt) == "string" then return srequest(reqt, body)
    else return trequest(reqt) end
end)

function request(reqt, body)
    if base.type(reqt) == "string" then return srequest(reqt, body)
    else return trequest(reqt) end
end

The latter makes my program work correctly (although I think the "connect"
function in COPAS needs a look - I already modified it a bit).

COPAS is replacing the socket.protect in the socket module, so it took me
a long time to suspect it could be wrong or insufficient. I think it only
works if the socket.http requests are only going to do blocking I/O and
never yield. I think ideally, if you are going to do http requests from
within a web server, those requests should be non-blocking.

--
Juri Munkki