'Stops the task thread. Synchronous!'

def stop(self, timeout=None):

    self._lock.acquire()
    try:
        if self._thread:
            self._queue.put_nowait(self._terminator)
            self._thread.join(timeout=timeout)
            self._thread = None
            self._thread_for_pid = None
    finally:
        self._lock.release()
