<s> """<STR_LIT>""" <EOL> try : <EOL> from queue import Queue , Empty <EOL> except ImportError : <EOL> from Queue import Queue , Empty <EOL> class ZMQSocketChannel ( object ) : <EOL> """<STR_LIT>""" <EOL> session = None <EOL> socket = None <EOL> stream = None <EOL> _exiting = False <EOL> proxy_methods = [ ] <EOL> def __init__ ( self , socket , session , loop = None ) : <EOL> """<STR_LIT>""" <EOL> super ( ZMQSocketChannel , self ) . __init__ ( ) <EOL> self . socket = socket <EOL> self . session = session <EOL> def _recv ( self , ** kwargs ) : <EOL> msg = self . socket . recv_multipart ( ** kwargs ) <EOL> ident , smsg = self . session . feed_identities ( msg ) <EOL> return self . session . deserialize ( smsg ) <EOL> def get_msg ( self , block = True , timeout = None ) : <EOL> """<STR_LIT>""" <EOL> if block : <EOL> if timeout is not None : <EOL> timeout *= <NUM_LIT:1000> <EOL> ready = self . socket . poll ( timeout ) <EOL> else : <EOL> ready = self . socket . poll ( timeout = <NUM_LIT:0> ) <EOL> if ready : <EOL> return self . _recv ( ) <EOL> else : <EOL> raise Empty <EOL> def get_msgs ( self ) : <EOL> """<STR_LIT>""" <EOL> msgs = [ ] <EOL> while True : <EOL> try : <EOL> msgs . append ( self . get_msg ( block = False ) ) <EOL> except Empty : <EOL> break <EOL> return msgs <EOL> def msg_ready ( self ) : <EOL> """<STR_LIT>""" <EOL> return bool ( self . socket . poll ( timeout = <NUM_LIT:0> ) ) <EOL> def close ( self ) : <EOL> if self . socket is not None : <EOL> try : <EOL> self . socket . close ( linger = <NUM_LIT:0> ) <EOL> except Exception : <EOL> pass <EOL> self . socket = None <EOL> stop = close <EOL> def is_alive ( self ) : <EOL> return ( self . socket is not None ) <EOL> def send ( self , msg ) : <EOL> """<STR_LIT>""" <EOL> self . session . send ( self . socket , msg ) <EOL> def start ( self ) : <EOL> pass </s>
