Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for repl hang when using with pyzmq => 18.0.0 #5252

Merged
merged 2 commits into from
Apr 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions Python/Product/PythonTools/ptvsd/repl/jupyter_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,26 +343,30 @@ 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:
bschnurr marked this conversation as resolved.
Show resolved Hide resolved
raise
except zmq.error.ZMQError:
self.exit_process()
except KeyboardInterrupt:
Expand Down