invisibleroads / socketIO-client

A socket.io client library for Python
http://pypi.python.org/pypi/socketIO-client
MIT License
447 stars 205 forks source link

run socketIO.wait in background thread cause KeyError/ValueError/... exceptions of received header #146

Closed adolli closed 7 years ago

adolli commented 7 years ago

I wrote a simple client with namespace connecting to my server and emit events to the namespaces. but some exceptions(maybe different each time) raised.

I put sio.wait in another thread because the main thread has other works to do. I have not use any critical resource and just print the received messages in my handler.

sio = SocketIO('localhost')
nsp = sio.define(handler, '/namespace')
t = threading.Thread(target=sio.wait)
t.start()
nsp.emit('xxx', {})  # exception raised here

# if start a thread after emit, the exception will not raise
# t = threading.Thread(target=sio.wait)
# t.start()

while True:
    time.sleep(1)  # endless loop

Could you please help me which I wrote in incorrect way.