What you really want to handle, is concurrency.
Asido from IRC have rewrote vicious gmail using luasocket. [0]
He said it returns immediately, if the network is completely down.
But still hangs if the network is slow.
The problem is that luasocket doesn't asynchronous http calls.
You have to use raw tcp sockets and implement http yourself (not so
good idea) [1]

I also test other libraries:
- libcurl: blocks too
- lualibevent & luaev: no http

There are some node.js clones out there like LuaNode.
But they embed lua instead of providing a library.

The best idea maybe is writing an asynchronous lua bindings for one of
the network libraries out there. (maybe libsoup[3])

The lack of lua libraries sucks sometimes.
Anyone who a have idea, how to solve this problem?
And I don't want solutions like dump curls output to disk.

[0] http://pastebin.com/HEmymFk6
[1] http://stackoverflow.com/questions/5795419/lua-socket-asynchronous-calls
[2] https://github.com/ignacio/LuaNode
[3] https://live.gnome.org/LibSoup

2011/12/8 Alexander Yakushev <[email protected]>:
> So here's my problem. I use a weather widget that fetches the data from a
> shell script via io.popen. It works great while I'm connected to the
> Internet but if I'm not it just freezes the entire WM. That's because the
> shell script itself doesn't print out anything and stays awaiting if it
> can't connect to the server. "ping" command also works like this, so I can't
> check if the system is online using it.
> If I am missing some other way to solve the problem then point me at it.
> Otherwise I see the only solution is to use some multithreading library to
> run IO requests asynchronously. Of course I can install library like that
> myself but I think that such facility could be useful for many users who
> want to extend their Awesome, and to the widget writers who could rely on it
> instead of distributing their widgets with such libraries themselves.
> So what do you think? Could a distant Awesome release contain a library like
> Lua Lanes (http://kotisivu.dnainternet.net/askok/bin/lanes/) or something
> similar?
>
> Regards,
> Alexander
>
> --
> To unsubscribe, send mail to [email protected].

-- 
To unsubscribe, send mail to [email protected].

Reply via email to