##// END OF EJS Templates
Merge pull request #5253 from minrk/console-async...
Min RK -
r15739:9338c65f merge
parent child Browse files
Show More
@@ -159,6 +159,8 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
159 should be set to False.
159 should be set to False.
160 """
160 """
161 if (not cell) or cell.isspace():
161 if (not cell) or cell.isspace():
162 # pressing enter flushes any pending display
163 self.handle_iopub()
162 return
164 return
163
165
164 if cell.strip() == 'exit':
166 if cell.strip() == 'exit':
@@ -180,7 +182,6 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
180 except Empty:
182 except Empty:
181 # display intermediate print statements, etc.
183 # display intermediate print statements, etc.
182 self.handle_iopub(msg_id)
184 self.handle_iopub(msg_id)
183 pass
184
185
185 # after all of that is done, wait for the execute reply
186 # after all of that is done, wait for the execute reply
186 while self.client.is_alive():
187 while self.client.is_alive():
@@ -222,26 +223,22 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
222 self.execution_count = int(content["execution_count"] + 1)
223 self.execution_count = int(content["execution_count"] + 1)
223
224
224
225
225 def handle_iopub(self, msg_id):
226 def handle_iopub(self, msg_id=''):
226 """ Method to process subscribe channel's messages
227 """Process messages on the IOPub channel
227
228
228 This method consumes and processes messages on the IOPub channel,
229 This method consumes and processes messages on the IOPub channel,
229 such as stdout, stderr, pyout and status.
230 such as stdout, stderr, pyout and status.
230
231
231 It only displays output that is caused by the given msg_id
232 It only displays output that is caused by this session.
232 """
233 """
233 while self.client.iopub_channel.msg_ready():
234 while self.client.iopub_channel.msg_ready():
234 sub_msg = self.client.iopub_channel.get_msg()
235 sub_msg = self.client.iopub_channel.get_msg()
235 msg_type = sub_msg['header']['msg_type']
236 msg_type = sub_msg['header']['msg_type']
236 parent = sub_msg["parent_header"]
237 parent = sub_msg["parent_header"]
237 if (not parent) or msg_id == parent['msg_id']:
238
239 if parent.get("session", self.session_id) == self.session_id:
238 if msg_type == 'status':
240 if msg_type == 'status':
239 state = self._execution_state = sub_msg["content"]["execution_state"]
241 self._execution_state = sub_msg["content"]["execution_state"]
240 # idle messages mean an individual sequence is complete,
241 # so break out of consumption to allow other things to take over.
242 if state == 'idle':
243 break
244
245 elif msg_type == 'stream':
242 elif msg_type == 'stream':
246 if sub_msg["content"]["name"] == "stdout":
243 if sub_msg["content"]["name"] == "stdout":
247 print(sub_msg["content"]["data"], file=io.stdout, end="")
244 print(sub_msg["content"]["data"], file=io.stdout, end="")
General Comments 0
You need to be logged in to leave comments. Login now