in pythonflow/pfmq/_base.py [0:0]
def cancel(self, timeout=None):
"""
Cancel the event loop running in a background thread.
Parameters
----------
timeout : float
Timeout for joining the background thread.
Returns
-------
cancelled : bool
Whether the background thread was cancelled. `False` if the background thread was not
running.
"""
if self.is_alive:
self._cancel_parent.send_multipart([b''])
self._thread.join(timeout)
self._cancel_parent.close()
return True
return False