en Python, estoy usando la siguiente:zeromq y bind_to_random_port - cómo conseguir el puerto elegido
context = zmq.Context()
socket = context.socket(zmq.PUSH)
socket.bind_to_random_port('tcp://*', min_port=6001, max_port=6004, max_tries=100)
port_selected = socket.???????
¿Cómo sé qué puerto se elige? Tendré una tabla de búsqueda en redis para que los trabajadores la lean.
Estoy utilizando un modelo de extracción por presión. Necesito que los trabajadores sepan a qué puertos conectarse.
Tengo que hacer esto porque estoy usando el bucle gevent en uwsgi y especificando un thur ciego simple y error debido a un tenedor. Si un uso bind_to_random_port se selecciona un puerto, simplemente no sé cuál.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent-1.0b2-py2.7-linux-x86_64.egg/gevent/greenlet.py",
line 328, in run
result = self._run(*self.args, **self.kwargs)
File "/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbUwsgiPixelServer/uwsgiPixelServer.py",
line 43, in sendthis
socket.send(push)
File "/usr/local/lib/python2.7/dist-packages/zmq/green/core.py",
line 173, in send
self._wait_write()
File "/usr/local/lib/python2.7/dist-packages/zmq/green/core.py",
line 108, in _wait_write
assert self.__writable.ready(), "Only one greenlet can be waiting
on this event"
AssertionError: Only one greenlet can be waiting on this event
<Greenlet at 0x2d41370: sendthis('2012-07-02 04:05:15')> failed with
AssertionError
referencia: http://zeromq.github.com/pyzmq/api/zmq.html#zmq.Socket.bind_to_random_port – odigity