with timeout(...):

Nick Craig-Wood nick at craig-wood.com
Sat Mar 31 11:30:03 CEST 2007


John Nagle <nagle at animats.com> wrote:
>  Diez B. Roggisch wrote:
> > Nick Craig-Wood wrote:
> > 
> > 
> >>Did anyone write a contextmanager implementing a timeout for
> >>python2.5?
> >>
> >>And have it work reliably and in a cross platform way!
> > 
> > Cross platform isn't the issue here - reliability though is. To put it
> > simple: can't be done that way. You could of course add a timer to the
> > python bytecode core, that would "jump back" to a stored savepoint or
> > something like that.
> 
>       Early versions of Scheme had a neat solution to this problem.
>  You could run a function with a limited amount of "fuel".  When the
>  "fuel" ran out, the call returned with a closure.  You could
>  run the closure again and pick up from where the function had been
>  interrupted, or just discard the closure.

That sounds like a really nice concept.  That would enable you to make
long running stuff yield without threads too.

I wonder if it is possible in python...

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list