diff --git a/py/client-ticking/src/pydeephaven_ticking/table_listener.py b/py/client-ticking/src/pydeephaven_ticking/table_listener.py index 6bcbbfbf282..2d9891e355c 100644 --- a/py/client-ticking/src/pydeephaven_ticking/table_listener.py +++ b/py/client-ticking/src/pydeephaven_ticking/table_listener.py @@ -216,9 +216,12 @@ def stop(self) -> None: This can happen if the user's callback calls stop().""" self._cancelled = True + if threading.get_ident() == self._thread.ident: + # We are inside the callback, so just setting the 'cancelled' flag suffices. + return + self._reader.cancel() - if threading.get_ident() != self._thread.ident: - self._thread.join() + self._thread.join() def _process_data(self): """This method continuously runs on a separate thread. It processes incoming Barrage messages, feeds them to