I'm working on a threading server in Python but I'm running into problems with one connection blocking. When I make the first connection, it sleeps and then I don't get anything back on the second connection to the server until the first is done sleeping. Any thoughts on what I'm doing wrong?
import socket, ssl, time, threading
def test_handler(conn):
print "sleeping 10 seconds"
time.sleep(10)
conn.write("done sleeping")
return 0
class ClientThread(threading.Thread):
def __init__(self, connstream):
threading.Thread.__init__(self)
self.conn = connstream
def run(self):
test_handler(self.conn)
threads = []
bindsocket = socket.socket()
bindsocket.bind(('0.0.0.0', 10023))
bindsocket.listen(10)
while True:
newsocket, fromaddr = bindsocket.accept()
connstream = ssl.wrap_socket(newsocket,
server_side=True,
certfile="server.crt",
keyfile="server.key",
ssl_version=ssl.PROTOCOL_TLSv1)
try:
c = ClientThread(connstream)
c.start()
threads.append(c)
finally:
for t in threads:
t.join()