[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaSocket - COPAS - CoSocket
- From: jm_list@...
- Date: Thu, 10 May 2007 06:22:17 -0700 (PDT)
> 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