AyWa commented on a change in pull request #3337: [ZEPPELIN-4078] Ipython queue 
performance
URL: https://github.com/apache/zeppelin/pull/3337#discussion_r267647327
 
 

 ##########
 File path: python/src/main/resources/grpc/python/ipython_server.py
 ##########
 @@ -52,24 +52,19 @@ def execute(self, request, context):
         print("execute code:\n")
         print(request.code.encode('utf-8'))
         sys.stdout.flush()
-        stdout_queue = queue.Queue(maxsize = 10)
-        stderr_queue = queue.Queue(maxsize = 10)
-        image_queue = queue.Queue(maxsize = 5)
-
+        stream_reply_queue = queue.Queue(maxsize = 20)
+        payload_reply = []
         def _output_hook(msg):
             msg_type = msg['header']['msg_type']
             content = msg['content']
             if msg_type == 'stream':
-                stdout_queue.put(content['text'])
+                
stream_reply_queue.put(ipython_pb2.ExecuteResponse(status=ipython_pb2.SUCCESS, 
type=ipython_pb2.TEXT, output=content['text']))
+            elif msg_type == 'error':
+                
stream_reply_queue.put(ipython_pb2.ExecuteResponse(status=ipython_pb2.ERROR, 
type=ipython_pb2.TEXT, output='\n'.join(content['traceback'])))
             elif msg_type in ('display_data', 'execute_result'):
-                stdout_queue.put(content['data'].get('text/plain', ''))
+                
stream_reply_queue.put(ipython_pb2.ExecuteResponse(status=ipython_pb2.SUCCESS, 
type=ipython_pb2.TEXT, output=content['data'].get('text/plain', '')))
                 if 'image/png' in content['data']:
-                    image_queue.put(content['data']['image/png'])
-            elif msg_type == 'error':
-                stderr_queue.put('\n'.join(content['traceback']))
-
-
-        payload_reply = []
+                    
stream_reply_queue.put(ipython_pb2.ExecuteResponse(status=ipython_pb2.SUCCESS, 
type=ipython_pb2.IMAGE, output=content['data']['image/png']))
 
 Review comment:
   Sure let me update that.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to