Macaulay2 » Documentation
Packages » RunExternalM2 :: RunExternalM2
next | previous | forward | backward | up | index | toc

RunExternalM2 -- a package to run Macaulay2 code externally and retrieve the result


This package allows the user to run a Macaulay2 function in a brand-new instance of Macaulay2, wait for the instance to finish, and automatically retrieve any results. This is primarily done with the runExternalM2 function.

One of the main purposes of this package is to allow the use of operating system features (e.g., ulimit on Unix-like systems) to restrict the resources (e.g., memory, running time) that the Macaulay2 function is allowed to use; see resource limits. This is particularly useful if you want a computation to give up after a certain amount of time, as an alternative to using alarm and try.

For example, suppose you want to find an example of an ideal that has a particular property, and the time required to check for this property can vary enormously. First write a Macaulay2 function foo() that generates a random ideal I and checks whether I has this property. Then use a loop to repeatedly call foo() using runExternalM2, with a time limit of 20 seconds, until such an ideal is found; now let it run overnight.

For examples, please see runExternalM2 or suggestions for using RunExternalM2.

See also



This documentation describes version 0.83 of RunExternalM2.

Source code

The source code from which this documentation is derived is in the file RunExternalM2.m2.


  • Functions and commands
  • Symbols
    • KeepStatisticsCommand -- an option that tells how to collect statistics
    • PreRunScript -- a way to impose resource limits
    • KeepStatistics -- see runExternalM2 -- run a Macaulay2 function in a new Macaulay2 process
    • M2Location -- see runExternalM2 -- run a Macaulay2 function in a new Macaulay2 process

For the programmer

The object RunExternalM2 is a package.