ZMQ python socket from context catch exception -
i have nginx server uwsgi , python pyzmq (installed sudo pip install pyzmq).
i'm trying create socket zmq context, grab exception.
import zmq import os import sys cgi import parse_qs, escape sys.path.append('/usr/share/nginx/www/application') os.environ['python_egg_cache'] = '/usr/share/nginx/www/.python-egg' def application(environ, start_response): ctx = zmq.context() try: message = 'everything ok' s = ctx.socket(zmq.req) except exception e: message = "exception({0}): {1}".format(e.errno, e.strerror) pass response_headers = [('content-type', 'text/plain'), ('content-length', str(len(message)))] start_response('200 ok', response_headers); homecoming [message]
it raised exception
exception(14): bad address
if commented line
s = ctx.socket(zmq.req)
then ok.
i searched on internet, nobody has same problem.
please, have idea, doing wrong?
edit:
i wrote simple python script, working , response recv:
import zmq import os import sys print 'create zeromq instance...' ctx = zmq.context() print 'create socket ...' try: s = ctx.socket(zmq.req) except exception e: print "exception({0}): {1}".format(e.errno, e.strerror) sys.exit() s.connect('tcp://localhost:5555') s.send('fttt;') message = s.recv() print message
i seems problem uwsgi run python zmq, why?
presumably intend utilize socket somewhere below http response? because @ moment you're not connecting or binding on anything, makes "bad address" exception strange. seek creating minimal illustration without cgi, nginx, cache, response stuff, zmq context creation , socket creation , see if raise same exception. if so, appears there's wonky in binding or library. create sure installed correctly , versions compatible.
python sockets nginx zeromq uwsgi
No comments:
Post a Comment