multithreading - Threading socket server in Python -


I am working in Python on a threading server, but I'm running into problems with blocking a connection. When I make the first connection, it sleeps and by then I do not take back the first connection on the server until it first sleeps. Any ideas on what I'm doing wrong?

  import socket, SSL, time, defing test_handler (conn) threading: print "sleeping 10 seconds" time.sleep (10) conn.write "done") 0 square clientTrade ( Threading Thread): def __init __ (self, connstream): Threading. Thread .__ init __ (self) self.conn = connstream def run (auto): test_handler (self.conn) thread = [] Bindsocket = socket.socket () bindsocket.bind (('0.0.0.0', 10023)) Bindsocket.listen (10) While true: newsbook, fromaddr = bindsocket.accept () connstream = ssl.wrap_socket (newsbook, 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 threads in T: T.join ()  

This block is because you join your new thread (and all others) after the installation of each new connection. By the time the thread ends, the blocks only call when you really want to wait until the thread.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -