summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/echoapp_client.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/examples/echoapp_client.py b/examples/echoapp_client.py
index e5232f7..c77bbbd 100644
--- a/examples/echoapp_client.py
+++ b/examples/echoapp_client.py
@@ -1,5 +1,8 @@
import websocket
-import thread
+try:
+ import thread
+except ImportError: #TODO use Threading instead of _thread in python3
+ import _thread
import time
import sys
@@ -29,7 +32,11 @@ def on_open(ws):
ws.close()
print("Thread terminating...")
- thread.start_new_thread(run, ())
+ try:
+ thread.start_new_thread(run, ())
+ except:
+ _thread.start_new_thread(run, ())
+
if __name__ == "__main__":
websocket.enableTrace(True)