Skip to content

Commit

Permalink
fix for repl hang when using with pyzmq => 18.0.0 (#5252)
Browse files Browse the repository at this point in the history
 fix for repl hang when using  with pyzmq => 18.0.0

- Both execute(..) and get_shell_msg(..) act on the same shell socket and having a blocking call to get_shell_msg(..) no longer works with the newer pyzmq.
- temporary fix was to downgrade pyzmq to 17.1.3
- Changed get_shell_msg(..) to use a timeout instead of blocking.

related to bug  #5233
  • Loading branch information
bschnurr authored Apr 23, 2019
1 parent 79f4c39 commit a9266fc
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions Python/Product/PythonTools/ptvsd/repl/jupyter_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,25 +343,28 @@ def __shell_threadproc(self, client):
if self.exit_requested:
break

m = Message(client.get_shell_msg(block=True))
msg_id = m.msg_id
msg_type = m.msg_type

print('%s: %s' % (msg_type, msg_id))

exec_count = m.content['execution_count', None]
if exec_count != last_exec_count and exec_count is not None:
last_exec_count = exec_count
exec_count = int(exec_count) + 1
ps1 = 'In [%s]: ' % exec_count
ps2 = ' ' * (len(ps1) - 5) + '...: '
self.send_prompt('\n' + ps1, ps2, allow_multiple_statements=True)

parent_id = m.parent_header['msg_id', None]
if parent_id:
on_reply = on_replies.pop((parent_id, msg_type), ())
for callable in on_reply:
callable(m)
try:
m = Message(client.get_shell_msg(timeout=0.1))
msg_id = m.msg_id
msg_type = m.msg_type

print('%s: %s' % (msg_type, msg_id))

exec_count = m.content['execution_count', None]
if exec_count != last_exec_count and exec_count is not None:
last_exec_count = exec_count
exec_count = int(exec_count) + 1
ps1 = 'In [%s]: ' % exec_count
ps2 = ' ' * (len(ps1) - 5) + '...: '
self.send_prompt('\n' + ps1, ps2, allow_multiple_statements=True)

parent_id = m.parent_header['msg_id', None]
if parent_id:
on_reply = on_replies.pop((parent_id, msg_type), ())
for callable in on_reply:
callable(m)
except Empty:
pass

except zmq.error.ZMQError:
self.exit_process()
Expand Down

0 comments on commit a9266fc

Please sign in to comment.