Re: A better way to timeout a class method?

2009-03-10 Thread John O'Hagan
On Mon, 9 Mar 2009, Nick Craig-Wood wrote: John O'Hagan resea...@johnohagan.com wrote: Is there a concise Pythonic way to write a method with a timeout? I did this: class Eg(object): def get_value(self, timeout): from threading import Timer self.flag

A better way to timeout a class method?

2009-03-09 Thread John O'Hagan
Is there a concise Pythonic way to write a method with a timeout? I did this: class Eg(object): def get_value(self, timeout): from threading import Timer self.flag = True def flag_off(): self.flag = False timer = Timer(timeout, flag_off)

Re: A better way to timeout a class method?

2009-03-09 Thread Marco Mariani
John O'Hagan wrote: Is there a concise Pythonic way to write a method with a timeout? No need for threading. Just define a signal handler and call signal.alarm(). See the example at the end of the page: http://docs.python.org/library/signal.html --

Re: A better way to timeout a class method?

2009-03-09 Thread Nick Craig-Wood
Marco Mariani ma...@sferacarta.com wrote: John O'Hagan wrote: Is there a concise Pythonic way to write a method with a timeout? No need for threading. Just define a signal handler and call signal.alarm(). See the example at the end of the page:

Re: A better way to timeout a class method?

2009-03-09 Thread Nick Craig-Wood
John O'Hagan resea...@johnohagan.com wrote: Is there a concise Pythonic way to write a method with a timeout? I did this: class Eg(object): def get_value(self, timeout): from threading import Timer self.flag = True def flag_off():

Re: A better way to timeout a class method?

2009-03-09 Thread John O'Hagan
On Mon, 9 Mar 2009, Marco Mariani wrote: John O'Hagan wrote: Is there a concise Pythonic way to write a method with a timeout? No need for threading. Just define a signal handler and call signal.alarm(). Thanks, that works well in general; but unfortunately the method in question (see the