invisibleroads / invisibleroads/socketIO-client
listener and send data as 2 threads
- Dominant language
- Python
- Stars
- 441
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
my python application connects to a socketIO server. i need 2 thread. first thread alway listen from server. and second thread alway send data to server every 1 minutes. I'd like to ask how to manage connection
```
def listener():
print ("PIDLISTEN="+str(os.getpid()))
print("Listening..")
socketIO = SocketIO('https://'+hostIO, transports=['xhr-polling', 'websocket'])
while True:
socketIO.wait(seconds=60)
def monitoring():
global token
socketIO = SocketIO('https://'+hostIO, transports=['xhr-polling', 'websocket'])
socketIO.emit('authenticate',{'token':token})
while True:
socketIO.emit('update',{'data':10}})
sys.stdout.flush()
time.sleep(60)
if __name__ == '__main__':
global token,stop_threads
thread1 = threading.Thread(target=listener, args=())
thread1.daemon = True
thread2 = threading.Thread(target=monitoring, args=())
thread2.daemon = True
thread1.start()
thread2.start()
while True:
print("Main program is sleeping.")
time.sleep(5)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.