Skip to content

Commit fd94369

Browse files
committed
1 parent ace2765 commit fd94369

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

ws4py/client/threadedclient.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ def daemon(self, flag):
4848
"""
4949
self._th.daemon = flag
5050

51+
def run_forever(self):
52+
"""
53+
Simply blocks the thread until the
54+
websocket has terminated.
55+
"""
56+
self._th.join()
57+
5158
def handshake_ok(self):
5259
"""
5360
Called when the upgrade handshake has completed
@@ -56,7 +63,6 @@ def handshake_ok(self):
5663
Starts the client's thread.
5764
"""
5865
self._th.start()
59-
self._th.join(timeout=1.0)
6066

6167
if __name__ == '__main__':
6268
from ws4py.client.threadedclient import WebSocketClient
@@ -77,5 +83,6 @@ def received_message(self, m):
7783
try:
7884
ws = EchoClient('ws://localhost:9000/ws', protocols=['http-only', 'chat'])
7985
ws.connect()
86+
ws.run_forever()
8087
except KeyboardInterrupt:
8188
ws.close()

0 commit comments

Comments
 (0)