- # wait for websocket thread to finish up (closed() is called by
- # websocket thread in as part of terminate())
- while not self.stop.is_set():
- self.stop.wait(1)
+ :timeout: is the number of seconds to wait for ws4py to
+ indicate that the connection has closed.
+ """
+ super(EventClient, self).close(code, reason)
+ with self._closing_lock:
+ # make sure we don't process any more messages.
+ self._closing = True
+ # wait for ws4py to tell us the connection is closed.
+ self._closed.wait(timeout=timeout)