Another non blocking method in thread

Prashant animator333 at gmail.com
Sun Jun 10 14:38:13 CEST 2012


Hi,

I have created a very simple client-server model using sockets. Server is created by sub classing threading.thread. The 'run' method is continuously listening for client's response. When server send a string to client, client response back by changing that string into uppercase.
I would like to synchronize send and receive. For example:

def sendmsg(self, msg):
    self.client.send(msg)
    #wait until next msg is received in 'run'
    return self.response

I tried using a while loop for waiting but it's blocking the 'run' method. Don't know much about threading event and lock and if they can help me here.

Any pointers?

Prashant


More information about the Python-list mailing list