send with timeout socket

Bryan Olson fakeaddress at nowhere.org
Fri Sep 22 11:03:10 EDT 2006


Stéphane Ninin wrote:
> Yes, I typed it *really* too fast, it would be more something like this:
>    
>     def sendall(self, data):
>         while data:
>             try:
>                 n = self.request.send(data)
>                 data = data[n:]
>             except socket.timeout, e:
>                 if self.isTerminated():
>                     return

And from a previous post:

   (self.isTerminated just checks is some event has been set
    by another thread)

Do you want to timeout on inactivity, or do you want to timeout
if sendall() does not complete within a given time?


-- 
--Bryan



More information about the Python-list mailing list