def react(reactor, main, argv):
stopping = []<EOL>reactor.addSystemEventTrigger('<STR_LIT>', '<STR_LIT>', stopping.append, True)<EOL>finished = main(reactor, *argv)<EOL>finished.addErrback(err, "<STR_LIT>")<EOL>def cbFinish(ignored):<EOL><INDENT>if not stopping:<EOL><INDENT>reactor.callWhenRunning(reactor.stop)<EOL><DEDENT><DEDENT>finished.addCallback(cbFinish)<EOL>reactor.run()<EOL>
Call C{main} and run the reactor until the L{Deferred} it returns fires.

@param reactor: An unstarted L{IReactorCore} provider which will be run and
    later stopped.

@param main: A callable which returns a L{Deferred}.  It should take as
    many arguments as there are elements in the list C{argv}.

@param argv: A list of arguments to pass to C{main}.

@return: C{None}