id like to write a handler for the standalone server coming with pywebsocket (http://code.google.com/p/pywebsocket) that uses a thread. in the example coming with pywebsocket the handler is just a file with a function:
def web_socket_transfer_data(request):
while True:
line = request.ws_stream.receive_message()
if line is None:
return
request.ws_stream.send_message(line)
if line == _GOODBYE_MESSAGE:
return
ive tried to add a thread:
class _Stub(threading.Thread):
def __init__ (self):
threading.Thread.__init__(self)
self._test = 0
def run(self):
while True:
time.sleep(5)
self._test = self._test + 1
but the server crashes without any comment... so how is this done?
thanks for any pointers.