#NEWLINE# def runserver( handshake_port ) : #NEWLINE# #INDENT# sock = zmq . Context ( ) . socket ( zmq . REP ) #NEWLINE# appport = sock . bind_to_random_port ( 'tcp://127.0.0.1' ) #NEWLINE# log . info ( 'Handshaking on %s, sending %s' , handshake_port , appport ) #NEWLINE# log . info ( 'Handshake finished, looping.' ) #NEWLINE# while True : #NEWLINE# #INDENT# recved = json . loads ( sock . recv ( ) ) #NEWLINE# log . debug ( 'recv: %s' , recved ) #NEWLINE# log . debug ( 'send: %s' , tosend ) #NEWLINE# sock . send ( json . dumps ( tosend ) )