[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LuaSocket - COPAS - CoSocket
- From: jm_list@...
- Date: Thu, 10 May 2007 01:51:31 -0700 (PDT)
I have been trying to use COPAS to do asynchronous HTTP requests. I keep
getting the "attempt to yield across metamethod/C-call boundary" error
even after I converted my pcalls to calls etc.
function DoAsyncRequest(request)
local t = {};
local wrapper = copas.wrap;
local tcpsocket = socket.tcp;
local requestTable = {
url = request,
sink = ltn12.sink.table(t),
create = copas.cosocket.tcp
};
local code, headers, status = socket.skip(1,
socket.http.request(requestTable));
return table.concat(t), code, headers, status;
end
myUrl = "http://ws.bonware.com/eps/e/lastWeather";
function TestURL()
print("Trying to get URL");
print(DoAsyncRequest(myUrl));
print("Done");
end
copas.addthread(TestURL);
copas.loop();
I didn't have any problems with coroutines when I implemented a simple
scheduler/coroutine thread system.
Since COPAS is a part of Kepler/Xavante, I assume it must be working for
someone.
All I really need is a way to do (mostly) non-blocking HTTP, so I may end
up abandoning COPAS and socket.http and implementing something simpler
using socket.tcp with zero timeouts.
For a language as beautifully designed as Lua, the limitations on
coroutines seem very vague and constricting.
--
Juri Munkki