code: def stop(self, timeout=1.0):
          
          if timeout:
              self._running.wait(timeout)
          self._running.clear()
          # Make sure to wake the run thread.
          self._wake.set()
docs: Stop the handler thread (from another thread).
  
          Parameters
          ----------
          timeout : float, optional
              Seconds to wait for server to have *started*.