[zeromq-dev] pyzmq on uwsgi process question
郭梁
g65537 at gmail.com
Mon Oct 10 11:27:44 CEST 2011
oops! my mistake !
http://lists.unbit.it/pipermail/uwsgi/2011-January/001269.html
2011/10/10 郭梁 <g65537 at gmail.com>
> hello everyone
>
> I have an application based on zeromq-2.1.10 & pyzmq-2.1.9, the
> architecture looks like this:
> --------------------------------------------------------------------
> nginx(uwsgi) REQ
> \ | /
> / | \
> backend worker1 worker2 .... workerN REP
> --------------------------------------------------------------------
> for some reasons, I do not intend to use the XREP/XREQ model, and each
> back-end worker has its own address, the front-end through a certain
> algorithm to determine the back-end workers, by "ipc://..." way
> communication.
> Independent testing everything looks normal, but on the uwsgi process, i
> got the error code: http 502
> The following is a simplified front-end code:
> --------------------------------------------------------------------
> #!/usr/bin/env python
>
> import random
> import zmq
>
> num_workers = 32
> socket_workers = []
> context = zmq.Context()
>
> for i in range(num_workers):
> socket = context.socket(zmq.REQ)
> socket.connect("ipc:///dev/shm/april/worker%d.ipc" % i)
> socket_workers.append(socket)
>
> def run(environ):
> i = random.randint(0, 32)
> socket_workers[i].send_pyobj({})
> return str(socket_workers[i].recv_json())
>
> def application(environ, start_response):
> status = '200 OK'
> output = run(environ)
> response_headers = [('Content-type', 'text/plain'), ('Content-Length',
> str(len(output)))]
> start_response(status, response_headers)
> return [output]
>
> # for Test
> if __name__ == "__main__":
> print run(None)
> --------------------------------------------------------------------
> can anyone share their experience and thoughts on this?
> regards
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20111010/aec072ac/attachment.htm>
More information about the zeromq-dev
mailing list