Adding idle timeout capabilities to asyncore

Paul Rubin http
Thu Oct 25 01:20:14 EDT 2007


Giampaolo Rodola' <gnewsg at gmail.com> writes:
> def readable(self):
>     if time.time() >= self.timeout:
>         self.send("Timeout")
>         self.close()
>     return 1

Don't do it this way.  Put all the timeouts into a priority queue
(see the heapq module) so you only need to check the one due to expire
soonest.



More information about the Python-list mailing list