Limiting execution time of commands

16 views
Skip to first unread message

nilten

unread,
Dec 18, 2010, 3:41:41 AM12/18/10
to Macaulay2
Hi,

Is there any way of telling Macaulay2 to only run a command up to a
certain time limit?

For example, I have a list L consisting of homogeneous ideals, I would
like to do

"apply(L,I->(numgens source basis(0,Hom(I,(Ring I)/I))))"

but for some of the ideals, this calculation will probably not
finish. Can I tell Macaulay2 that it should give up after trying for
say, 120 seconds, and move on to the next ideal?

Thanks in advance for any help,
Nathan

Dan Grayson

unread,
Dec 19, 2010, 10:49:57 AM12/19/10
to Macaulay2
You can use "alarm" to produce an error after a certain number of
seconds and use "try" to ensure that the program continues. Sadly,
there is currently no way to distinguish an alarm error from any other
kind of error. Another approach would be to start another M2 process
with a time limit. When threads are implemented well, that will be
another way to go.

nilten

unread,
Dec 20, 2010, 5:26:28 AM12/20/10
to Macaulay2
Thanks, this will work for my purposes.
Reply all
Reply to author
Forward
0 new messages