How to set a timeout?

Marco Mariani m.mariani at imola.nettuno.it
Wed Jul 18 15:47:27 CEST 2001


On Wed, Jul 18, 2001 at 03:40:19PM +0200, Marco Mariani wrote:

> From one of my sources:
> 
> 
> 
> from signal import *
> 
> 
> def timeout(signum, frame):
> 	raise IOError, "Timeout!"
> 
> 	def alarm_on(self):
> 		signal(SIGALRM, timeout)
> 		alarm(1)
> 
> 	def alarm_off(self):
> 		alarm(0)

Oops, I've mistaken the tab count.

Of course the alarm_* functions above are outside the timeout function!





More information about the Python-list mailing list