/usr/lib/python2.7/dist-packages/epsilon/react.py is in python-epsilon 0.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # -*- test-case-name: epsilon.test.test_react -*-
# Copyright (c) 2008 Divmod. See LICENSE for details.
"""
Utilities for running the reactor for a while.
"""
from twisted.python.log import err
def react(reactor, main, argv):
"""
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}
"""
stopping = []
reactor.addSystemEventTrigger('before', 'shutdown', stopping.append, True)
finished = main(reactor, *argv)
finished.addErrback(err, "main function encountered error")
def cbFinish(ignored):
if not stopping:
reactor.callWhenRunning(reactor.stop)
finished.addCallback(cbFinish)
reactor.run()
|