[uWSGI] Incompatibility between PyZMQ and uWSGI

Jaime Fernández jjjaime at gmail.com
Thu Nov 25 13:06:18 CET 2010


Finally, I found I identified the problem but I don't know why.

According to ZMQ specification, the ZMQ context should be shared to create
all the ZMQ sockets of the same process. What we did, is to create a Python
module which creates such ZMQ context:

# zmq_context.py
import zmq
context = zmq.Context()

If you create the following WSGI app:

import zmq
import zmq_context
def application(environ, start_response):
    context = zmq_context.context
    socket_push = context.socket(zmq.PUSH)
    socket_push.connect('tcp://localhost:9876')
    socket_push.send_multipart(["Hello", "World"])

Then uWSGi dies when zmq tries to connect to the ZQM socket.

However, if we don't use the zmq_context module and create the context
directly:

import zmq
def application(environ, start_response):
    context = zmq.Context()
    socket_push = context.socket(zmq.PUSH)
    socket_push.connect('tcp://localhost:9876')
    socket_push.send_multipart(["Hello", "World"])

Everything works.

Why? I cannot see any difference. And, as I said, it works with wsgiref (I
haven't tested with other WSGi servers)

Thanks in advance,
Jaime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.unbit.it/pipermail/uwsgi/attachments/20101125/0d21f670/attachment.htm 


More information about the uWSGI mailing list