本文整理汇总了Python中twisted.internet.task.react函数的典型用法代码示例。如果您正苦于以下问题:Python react函数的具体用法?Python react怎么用?Python react使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了react函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
"""
Schedules the startRequests method and gracefully exits the program when either
all of the deferred objects fire successfully or fail
"""
task.react(self._startRequests)
示例2: main
def main():
"""
"""
logger = setLogger()
currencies_responses = get_responses(200)
logger.debug("Got responses")
currencies_soups = collect_soups(currencies_responses)
logger.debug("Got soups")
curr_short_rate_names = collect_short_rate_names(currencies_soups)
logger.debug("Collected short rate names")
short_rate_names_to_parse = prepare_for_parse(curr_short_rate_names)
logger.debug("Got short rate names to parse")
short_rate_names_responses = get_short_rate_names_responses(
short_rate_names_to_parse)
logger.debug("Got short rate names responses")
short_rate_names_trees = collect_short_rate_names_trees(
short_rate_names_responses)
logger.debug("Collected short rate names trees")
hash_table = create_hash_table(short_rate_names_trees,
short_rate_names_to_parse)
logger.debug("Created hash_table")
create_currencies_tables('userdb',
curr_short_rate_names,
hash_table,
)
logger.debug("Created currencies table")
task.react(graph_id_parser, (curr_short_rate_names,))
示例3: run
def run(components, log_level='info'):
"""
High-level API to run a series of components.
This will only return once all the components have stopped
(including, possibly, after all re-connections have failed if you
have re-connections enabled). Under the hood, this calls
:meth:`twisted.internet.reactor.run` -- if you wish to manage the
reactor loop yourself, use the
:meth:`autobahn.twisted.component.Component.start` method to start
each component yourself.
:param components: the Component(s) you wish to run
:type components: Component or list of Components
:param log_level: a valid log-level (or None to avoid calling start_logging)
:type log_level: string
"""
# only for Twisted > 12
# ...so this isn't in all Twisted versions we test against -- need
# to do "something else" if we can't import .. :/ (or drop some
# support)
from twisted.internet.task import react
# actually, should we even let people "not start" the logging? I'm
# not sure that's wise... (double-check: if they already called
# txaio.start_logging() what happens if we call it again?)
if log_level is not None:
txaio.start_logging(level=log_level)
react(component._run, (components, ))
示例4: test
def test():
transports = [
{
'type': 'rawsocket',
'serializer': 'msgpack',
'endpoint': {
'type': 'unix',
'path': '/tmp/cb1.sock'
}
},
{
'type': 'websocket',
'url': 'ws://127.0.0.1:8080/ws',
'endpoint': {
'type': 'tcp',
'host': '127.0.0.1',
'port': 8080
}
}
]
connection1 = Connection(main1, transports=transports[0])
yield react(connection1.start)
connection2 = Connection(main2, transports=transports[1])
yield react(connection2.start)
示例5: cli
def cli(user, probes, results, verbose):
if False:
# writes a 'txtorcon.log' with debugging information
from txtorcon.log import debug_logging
debug_logging()
args = (user, probes, results, verbose)
react(main, args)
示例6: run
def run():
assert sys.version_info < (3,), u"Tahoe-LAFS does not run under Python 3. Please use Python 2.7.x."
if sys.platform == "win32":
from allmydata.windows.fixups import initialize
initialize()
# doesn't return: calls sys.exit(rc)
task.react(_run_with_reactor)
示例7: reactOn
def reactOn(self,d):
# def onEnd(response):
# reactor.stop()
# d.addBoth(onEnd)
# reactor.run()
def main(r):
return d
react(main)
示例8: main
def main(argv=None, _abort_for_test=False):
# This function is referenced by the setup.py entry point definition as well as the name=__main__ test below.
def go(reactor):
return _main_async(reactor, argv, _abort_for_test)
if _abort_for_test:
return go(singleton_reactor)
else:
react(go)
示例9: test_runsUntilSyncCallback
def test_runsUntilSyncCallback(self):
"""
L{react} returns quickly if the L{Deferred} returned by the function it
is passed has already been called back at the time it is returned.
"""
def main(reactor):
return defer.succeed(None)
r = _FakeReactor()
task.react(main, [], _reactor=r)
self.assertEqual(r.seconds(), 0)
示例10: _main
def _main():
"""
This is a magic name for `python -m autobahn`, and specified as
our entry_point in setup.py
"""
react(
lambda reactor: ensureDeferred(
_real_main(reactor)
)
)
示例11: main
def main(self, args=None):
parser = self.build_parser()
args = parser.parse_args(args)
self.verbose = args.verbose
action = self.find_action(args)
if not action:
parser.print_help()
sys.exit(2)
action_method = getattr(self, action + '_action')
task.react(action_method, [args])
示例12: main
def main(argv=sys.argv):
parser = argparse.ArgumentParser()
_curvecpm.addLogArguments(parser)
parser.add_argument('-n', '--name')
parser.add_argument('-e', '--server-extension', default='0' * 32)
parser.add_argument('keydir', type=Keydir)
parser.add_argument('port', type=int)
parser.add_argument('program')
parser.add_argument('argv', nargs='*')
react(twistedMain, [parser.parse_args(argv[1:])])
示例13: react_app
def react_app(app, main, argv=()):
@defer.inlineCallbacks
def appless_main(reactor):
yield defer.maybeDeferred(service.IService(app).startService)
try:
yield defer.maybeDeferred(main, *argv)
finally:
yield defer.maybeDeferred(service.IService(app).stopService)
task.react(appless_main)
示例14: main
def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser(description='Yarrharr fetch debug utility')
parser.add_argument('url')
args = parser.parse_args()
os.environ['DJANGO_SETTINGS_MODULE'] = 'yarrharr.settings'
import yarrharr.application
yarrharr.application
# TODO config logging
task.react(_txmain, [args.url])
示例15: main
def main():
parser = argparse.ArgumentParser()
parser.add_argument("hls_playlist")
parser.add_argument("-v", action="store_true")
parser.add_argument("-d", action="store_true")
parser.add_argument("--dump-durations", action="store_true")
parser.add_argument("--referer")
parser.add_argument("-o");
args = parser.parse_args()
react(runProxy, [args])