runMain ( factory )
Use factory to create and run a "main" program
factory must be adaptable to ICmdLineApp, ICmdLineAppFactory, or
IMainCmdFactory. In each case, it will be used to create and run a
"main program", whose run() method's return code will be passed to
sys.exit(). Example usage:
from peak.running import commands
class MyCommand(commands.AbstractCommand):
def _run(self):
print "Hello world!"
if __name__ == '__main__':
commands.runMain(MyCommand)
To support "child processes" created with PEAK's process management tools,
this function will check the run() method's return code to see if it is
another ICmdLineApp, ICmdLineAppFactory, or IMainCmdFactory. If so,
it will create and run a new "main program" based on that result, after
allowing the previous "main program" to be garbage collected. This looping
will continue until run() returns a non-command object.
|