multithreading - Python websocket client send in run loop -
i'm piping stdin
websocket using websocket-client. i'm connecting websocket this:
ws = websocketapp('ws://example.com/websocket') ws.run_forever(ping_interval=15)
run_forever
starts infinite loop. i'd simultaneously read sys.stdin
this:
while true: try: line = sys.stdin.readline() ws.send(line) except keyboardinterrupt: break if not line: break
is there way alternate between 2 loops threading? or approaching wrong way?
this done tornado or twisted, i'd rather keep dependencies @ minimum if there's way standard lib.
Comments
Post a Comment