I have upgraded from gevent 13.x to 1.0b4.
I have Failover code that checks if a connection is till alive by sending “HUGZ” every 5 seconds. If HUGZ’s fail to arrive a an alternative connection to a different location is made. This failover mechanism stopped working because Timeout behaviour changed.
I made some test code with a with Timeout and the and it works as expected,
BUT the exact same code does not work anymore in my the context of my application. The failover code used to work before.
I’m using gevent-zeromq to recv messages in a with TimeOut block, but the with TimeOut blocks, and never ‘times outs` and continues execution, so recovery code is not getting executed.
What could cause the Timeout mechanism not to be working?
The previously working Timeout code does not work anymore.
if active_socket:
print 'waiting for message'
with Timeout(2, False):
node_message = NodeMessage.recv(active_socket)
When no message arrives in time, the code block after this text
does not get executed. and it should!! and did before.
logging.info('ping..')
logging.info(node_message.name)
# deal with message from plc_server.
if node_message:
handle_node_message(plc_client, plc_server, node_message)
else:
# no nodemessage or hugz recieved.
# plc_server has died a horrible death? reboot?
The recv method:
@classmethod
def recv(cls, socket):
"""Reads name-value message from socket"""
while True:
message = socket.recv()
if message:
return cls.from_message(message)
The socket is a initialized in a connection object of which I have a few:
from gevent import Timeout
from gevent_zeromq import zmq
..yada yada yada...
self.subscriber = ctx.socket(zmq.SUB)
self.subscriber.setsockopt(zmq.SUBSCRIBE, '')
self.subscriber.connect('%s:%d' % (address, port + 1))
self.subscriber.linger = 0
yolk:
gevent-zeromq - 0.2.5 - active
gevent - 1.0b4 - active
greenlet - 0.4.0 - active
changeing:
to: