#NEWLINE# def run( self ) : #NEWLINE# #INDENT# "The thread's main activity.  Call start() instead." #NEWLINE# self . _create_socket ( ) #NEWLINE# self . _running = True #NEWLINE# while e . _running : #NEWLINE# #INDENT# if self . _pause : #NEWLINE# #INDENT# time . sleep ( self . time_to_dead ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# since_last_heartbeat = 0.0 #NEWLINE# request_time = time . time ( ) #NEWLINE# try : #NEWLINE# #INDENT# self . socket . send ( b'ping' ) #NEWLINE# #UNINDENT# except zmq . ZMQError as e : #NEWLINE# #INDENT# if ( e . errno == zmq . EFSM ) : #NEWLINE# #INDENT# time . sleep ( self . time_to_dead ) #NEWLINE# self . _create_socket ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . socket . recv ( zmq . NOBLOCK ) #NEWLINE# #UNINDENT# except zmq . ZMQError as e : #NEWLINE# #INDENT# if ( e . errno == zmq . EAGAIN ) : #NEWLINE# #INDENT# before_poll = time . time ( ) #NEWLINE# until_dead = ( self . time_to_dead - ( before_poll - request_time ) ) #NEWLINE# if ( until_dead > 0.0 ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . poller . poll ( ( 1000 * until_dead ) ) #NEWLINE# #UNINDENT# except zmq . ZMQError as e : #NEWLINE# #INDENT# if ( e . errno == errno . EINTR ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# since_last_heartbeat = ( time . time ( ) - request_time ) #NEWLINE# if ( since_last_heartbeat > self . time_to_dead ) : #NEWLINE# #INDENT# self . call_handlers ( since_last_heartbeat ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# until_dead = ( self . time_to_dead - ( time . time ( ) - request_time ) ) #NEWLINE# if ( until_dead > 0.0 ) : #NEWLINE# #INDENT# time . sleep ( until_dead ) #NEWLINE# #UNINDENT# break