Skip to content

Commit

Permalink
lock
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Peter committed Dec 8, 2022
1 parent a1386a9 commit aa92dee
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spyder_kernels/comms/frontendcomm.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ def _check_comm_reply(self):
"""
Send comm message to frontend to check if the iopub channel is ready
"""
if len(self._pending_comms) == 0:
return
for comm in self._pending_comms.values():
self._notify_comm_ready(comm)
with self.comm_lock:
if len(self._pending_comms) == 0:
return
for comm in self._pending_comms.values():
self._notify_comm_ready(comm)
self.kernel.io_loop.call_later(1, self._check_comm_reply)

def _notify_comm_ready(self, comm):
Expand All @@ -143,7 +144,8 @@ def _notify_comm_ready(self, comm):

def _comm_ready_callback(self, ret):
"""A comm has replied, so process all cached messages related to it."""
comm = self._pending_comms.pop(self.calling_comm_id, None)
with self.comm_lock:
comm = self._pending_comms.pop(self.calling_comm_id, None)
if not comm:
return
# Cached messages for that comm
Expand Down Expand Up @@ -177,7 +179,8 @@ def _comm_open(self, comm, msg):

# IOPub might not be connected yet, keep sending messages until a
# reply is received.
self._pending_comms[comm.comm_id] = comm
with self.comm_lock:
self._pending_comms[comm.comm_id] = comm
self._notify_comm_ready(comm)
self.kernel.io_loop.call_later(.3, self._check_comm_reply)

Expand Down

0 comments on commit aa92dee

Please sign in to comment.