Re: HTTP over Asynchronous AF_UNIX Socket in python

2015-01-26 Thread Marko Rauhamaa
Norah Jones nh.jone...@gmail.com:

 But this cannot work since normal socket will not work and thus i
 thought of `asyncore` module in python. To use asyncore module again i
 will have to subclass asyncore.dispatcher. This class also contains
 connect() method.

 Another problem is I don't know how asyncore module works and thus not
 able to find a way to mix the work of 1) listening forever, accept the
 connection, store id and the sock_fd.
 2) accept data from the process' agent sister process, retrieve the
 sock_fd by matching the id in the dictionary and send it through the
 AF_UNIX socket.

Asyncore was a nice idea, but you shouldn't build anything on top of it.
The newest Python versions have moved to a scheme called asyncio. Its
programming model is a bit unconventional and hasn't won me over yet.

Personally, I have found select.epoll(EPOLLET) plus a timer
implementation enough of a framework for all of my async needs.

Then comes HTTP support. The stdlib networking facilities are great for
quick scripting, but not really compatible with the asynchronous
paradigm. I have coded my protocols by hand myself.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HTTP over Asynchronous AF_UNIX Socket in python

2015-01-26 Thread Michael Torrie
On 01/26/2015 06:32 AM, Norah Jones wrote:
 Now my problem is the HTTP request which to be sent must go through
 AF_UNIX socket. 

The Python Twisted framework may be of use to you.  It's got a very
steep learning curve, but it's fairly easy to change the underlying byte
transport for any protocol they have implemented. In fact in the Twisted
docs, they show a web client accessing an HTTP server over a unix socket
(scroll down to the bottom of the page):

http://twisted.readthedocs.org/en/latest/web/howto/client.html

They show a client connecting to a Docker server which is speaking HTTP
over a unix socket.

Twisted is very powerful and flexible, and event-driven.
-- 
https://mail.python.org/mailman/listinfo/python-list