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
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)
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
--
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:
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():
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