<s> """<STR_LIT>""" <EOL> import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> import zlib <EOL> import gevent <EOL> import zmq . green as zmq <EOL> from emdr . conf import default_settings as settings <EOL> from emdr . daemons . relay . dedupers import is_message_duped <EOL> def run ( ) : <EOL> """<STR_LIT>""" <EOL> context = zmq . Context ( ) <EOL> receiver = context . socket ( zmq . SUB ) <EOL> receiver . setsockopt ( zmq . SUBSCRIBE , '<STR_LIT>' ) <EOL> for binding in settings . RELAY_RECEIVER_BINDINGS : <EOL> receiver . connect ( binding ) <EOL> sender = context . socket ( zmq . PUB ) <EOL> for binding in settings . RELAY_SENDER_BINDINGS : <EOL> sender . bind ( binding ) <EOL> def relay_worker ( message ) : <EOL> """<STR_LIT>""" <EOL> if is_message_duped ( message ) : <EOL> return <EOL> if settings . RELAY_DECOMPRESS_MESSAGES : <EOL> message = zlib . decompress ( message ) <EOL> sender . send ( message ) <EOL> logger . info ( "<STR_LIT>" ) <EOL> while True : <EOL> gevent . spawn ( relay_worker , receiver . recv ( ) ) </s>
