Skip to content

Commit

Permalink
Simplify should_dispatch_immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainCorlay committed Mar 31, 2021
1 parent 0ab59fc commit 4d06758
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 3 additions & 1 deletion ipykernel/inprocess/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ def _dispatch_to_kernel(self, msg):
raise RuntimeError('Cannot send request. No kernel exists.')

stream = kernel.shell_stream
kernel.dispatch_shell(msg)
self.session.send(stream, msg)
msg_parts = stream.recv_multipart()
kernel.dispatch_shell(msg_parts)
idents, reply_msg = self.session.recv(stream, copy=False)
self.shell_channel.call_handlers_later(reply_msg)

Expand Down
2 changes: 1 addition & 1 deletion ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def do_clear(self):
self.shell.reset(False)
return dict(status='ok')

def should_dispatch_immediately(self, msg, *args):
def should_dispatch_immediately(self, msg):
try:
msg_type = msg['header']['msg_type']
if msg_type in self.comm_msg_types:
Expand Down
8 changes: 2 additions & 6 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,7 @@ def dispatch_queue(self):
def _message_counter_default(self):
return itertools.count()

def should_dispatch_immediately(
self, msg, idents, dispatch
):
def should_dispatch_immediately(self, msg):
"""
This provides a hook for dispatching incoming messages
from the frontend immediately, and out of order.
Expand All @@ -423,9 +421,7 @@ def schedule_dispatch(self, msg, dispatch):

new_args = (msg, idents)

if self.should_dispatch_immediately(
msg, idents, dispatch
):
if self.should_dispatch_immediately(msg):
return self.io_loop.add_callback(dispatch, *new_args)

idx = next(self._message_counter)
Expand Down

0 comments on commit 4d06758

Please sign in to comment.