Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84596

HTTP over Asynchronous AF_UNIX Socket in python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <nh.jones01@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'receives': 0.04; 'method.': 0.07; 'skip:` 10': 0.07; 'socket': 0.07; 'host,': 0.09; 'http': 0.09; 'runs': 0.10; 'def': 0.12; 'stored': 0.12; 'recognizing': 0.16; 'self.sock': 0.16; 'subclass': 0.16; 'subject:python': 0.16; 'thanks,': 0.17; 'module': 0.19; 'solution.': 0.20; 'command': 0.22; 'accepted.': 0.22; 'sends': 0.24; 'sort': 0.25; 'respective': 0.29; 'thus': 0.29; 'matching': 0.30; 'mix': 0.30; 'along': 0.30; '(which': 0.31; 'requests': 0.31; 'class': 0.32; 'another': 0.32; 'running': 0.33; 'skip:_ 10': 0.34; 'could': 0.34; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'hi,': 0.36; 'message-id:@gmail.com': 0.38; 'process,': 0.38; 'to:addr:python- list': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'days': 0.60; 'incoming': 0.72; 'listening': 0.74; 'header :Reply-to:1': 0.77; 'reply-to:addr:gmail.com': 0.80; 'header :Return-Path:2': 0.84; 'subject:over': 0.84; 'connection,': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:to:from:reply-to:subject:message-id:mime-version :content-transfer-encoding:content-type; bh=+XaAEMkaWit6px85GiDCqhbD9OQGp1Nv1qpXV+goy3g=; b=nK9fZ1kOn0kIOkEG13gDt046YQKCrWgA7JQ9SoNOl9ECpZOCrQ7WrEM5EQ8dqjuv+e u1Vy/bcQJxPtwiWlxGR/OFT0DyLCoz6DNw/netV7sNvkgLeRgZG7nAI5WKO3DDkol/5n YjWJZPhfdKN0bQwTk+6/0Ky4YnViVFOKhb7A79SxjgcBUloH1RWAlvekfVBmp+LgsYTM L4IbVe4bor9TqguDYq+fPl0GgT03N3sxk8frE/QvOlwUrxnR/I70hLThhLmIxhi9Kyw1 sF8z+WLzj7kOnRXMzM/zs/e5R7+7xfSSZB+97IaKyMyJONWoJ3+BJsP6AAUpj/M5NTcj U92Q==
X-Received by 10.66.129.199 with SMTP id ny7mr19129900pab.82.1422279144059; Mon, 26 Jan 2015 05:32:24 -0800 (PST)
Date Mon, 26 Jan 2015 13:32:22 +0000
To python-list@python.org
From Norah Jones <nh.jones01@gmail.com>
Subject HTTP over Asynchronous AF_UNIX Socket in python
X-Priority 3
X-Mailer CatPHPMailer 5.1 (phpmailer.sourceforge.net)
MIME-Version 1.0
Content-Transfer-Encoding 8bit
Content-Type text/plain; charset="utf-8"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To Norah Jones <nh.jones01@gmail.com>
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18146.1422279152.18130.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1422279152 news.xs4all.nl 2877 [2001:888:2000:d::a6]:35411
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:84596

Show key headers only | View raw


Hi, 

The problem description:

There are set of processes running on my system say `process_set_1`. Build a process agent which runs an `asynchronous` socket listening to incoming requests from process_set_1. Each process sends an `id`. The agent stores these ids in a dictionary and sends response that ur id has been accepted. Now agent process receives some data from another process (which is some sort of sister process for the agent). This data contains id along with a command which is to be sent by the agent to the process_set_1 through HTTP client over `AF_UNIX` socket, since each process in process_set_1 has a HTTP listening CLI. The process agent sends an HTTP request by recognizing id stored in dictionary to the process_set_1. A service running in the process_set_1 routes this HTTP command to the respective process.

Now my problem is the HTTP request which to be sent must go through AF_UNIX socket. I got this solution.

    class UnixStreamHTTPConnection(httplib.HTTPConnection):
    
        def __init__(self, path, host='localhost/rg_cli',port=None, strict=None,
                     timeout=None):
            httplib.HTTPConnection.__init__(self, host, port=port, strict=strict,
                                            timeout=timeout)
            self.path=path
    
        def connect(self):
            self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            self.sock.connect(self.path)

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.

Please help since i have already spent 2 days digging it out. Sorry if could explain my problem very well.

Thanks,
Norah Jones

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

HTTP over Asynchronous AF_UNIX Socket in python Norah Jones <nh.jones01@gmail.com> - 2015-01-26 13:32 +0000
  Re: HTTP over Asynchronous AF_UNIX Socket in python Marko Rauhamaa <marko@pacujo.net> - 2015-01-26 16:12 +0200

csiph-web