Created
March 29, 2017 16:37
-
-
Save Garmelon/90ba9c247c48b62dde9b54f60cd3d573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ssl | |
import threading | |
import time | |
import websocket | |
from websocket import WebSocketException as WSException | |
SSLOPT = {"cert_reqs": ssl.CERT_NONE} | |
ws = None | |
def run(): | |
print("Connecting") | |
global ws | |
ws = websocket.create_connection( | |
"wss://euphoria.io/room/test/ws", | |
enable_multithread=True, | |
sslopt=SSLOPT | |
) | |
print("Connected") | |
while True: | |
try: | |
ws.recv() | |
except (WSException, ConnectionResetError): | |
return | |
thread = threading.Thread( | |
target=run, | |
name="testthread" | |
) | |
thread.start() | |
while not ws: | |
time.sleep(1) | |
print("Closing connection in .5s:") | |
time.sleep(.5) | |
#ws.abort() # uncomment for working program, leave commented out for segfault >:D | |
ws.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment