#NEWLINE# def consume( self , event ) : #NEWLINE# #INDENT# server_meta = event [ 'server_meta' ] #NEWLINE# environ = { #NEWLINE# #INDENT# 'REQUEST_METHOD' : 'SOCKET' , #NEWLINE# 'SCRIPT_NAME' : '' , #NEWLINE# 'PATH_INFO' : '/json/messages' , #NEWLINE# 'SERVER_NAME' : 'localhost' , #NEWLINE# 'SERVER_PORT' : 9993 , #NEWLINE# 'SERVER_PROTOCOL' : 'ZULIP_SOCKET/1.0' , #NEWLINE# 'wsgi.version' : ( 1 , 0 ) , #NEWLINE# 'wsgi.input' : StringIO ( ) , #NEWLINE# 'wsgi.errors' : sys . stderr , #NEWLINE# 'wsgi.multithread' : False , #NEWLINE# 'wsgi.multiprocess' : True , #NEWLINE# 'wsgi.run_once' : False , #NEWLINE# 'zulip.emulated_method' : 'POST' , #NEWLINE# #UNINDENT# } #NEWLINE# environ . update ( server_meta [ 'request_environ' ] ) #NEWLINE# request = WSGIRequest ( environ ) #NEWLINE# request . _request = event [ 'request' ] #NEWLINE# request . csrf_processing_done = True #NEWLINE# user_profile = get_user_profile_by_id ( server_meta [ 'user_id' ] ) #NEWLINE# request . _cached_user = user_profile #NEWLINE# resp = self . handler . get_response ( request ) #NEWLINE# server_meta [ 'time_request_finished' ] = time . time ( ) #NEWLINE# server_meta [ 'worker_log_data' ] = request . _log_data #NEWLINE# resp_content = resp . content #NEWLINE# result = { #NEWLINE# #INDENT# 'response' : ujson . loads ( resp_content ) , #NEWLINE# 'req_id' : event [ 'req_id' ] , #NEWLINE# 'server_meta' : server_meta , #NEWLINE# #UNINDENT# } #NEWLINE# redis_key = req_redis_key ( event [ 'req_id' ] ) #NEWLINE# self . redis_client . hmset ( redis_key , { #NEWLINE# #INDENT# 'status' : 'complete' , #NEWLINE# 'response' : resp_content , #NEWLINE# #UNINDENT# } ) #NEWLINE# queue_json_publish ( server_meta [ 'return_queue' ] , result , ( lambda e : None ) )