Thank you, that's exactly what I need!

Andrey

On May 26, 4:46 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
> On Mon, May 26, 2008 at 4:38 PM, Andrey Novoseltsev <[EMAIL PROTECTED]> wrote:
>
> > Is there any way to automatically terminate the current computation if
> > it takes longer than given amount of time (say, a minute)? I want it
> > to be inside a loop that will stop some iterations and continue, if
> > they are taking too long.
>
> Yes, I wrote something to do this a long time ago.
> Use the alarm command:
>
> {{{id
> alarm(3)
> for i in range(10):
>     print i
>     sleep(1)
> ///
>
> 0
> 1
> 2
> Traceback (most recent call last):        sleep(1)
>   File "/Users/was/s/local/lib/python2.5/site-packages/sympy/plotting/",
> line 3, in <module>
>
>   File "/Users/was/s/local/lib/python2.5/site-packages/sage/misc/misc.py",
> line 1345, in __mysig
>     raise KeyboardInterrupt, "computation timed out because alarm was
> set for %s seconds"%__alarm_time
> KeyboardInterrupt: computation timed out because alarm was set for 3 seconds
>
>
>
> }}}- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to