def run(r=None): if w.total > 1000: reactor.stop() return w.total += 1 df = launch_coroutine(wrap_task(reactor.callLater), w.do_some_things) df.addCallback(run) df.addErrback(set_event_error)
def test_rate_limited_logger(): injectLogger(verbose = True) log = RateLimitedLogger(logging.getLogger("myapp"), 1,1) log.info( "should be printed." ) log.info( "should not be printed" ) # but should log "discard" message. log.info( "also should not be printed" ) # should not logging of discard message. df = Deferred() reactor.callLater(3, df.callback, True) like_yield(df) log.info( "should also be printed" ) reactor.stop()
def _stop(self, r=None): assert thread.get_ident() == self.ident connections = list(self.single_sockets) for connection in connections: try: connection.close() except: pass reactor.suggestThreadPoolSize(0) try: reactor.stop() except RuntimeError: # exceptions.RuntimeError: can't stop reactor that isn't running pass
def foo(): reactor.stop() zuul = dana
def set_event_error(x): print "A critical error occured:", str(x[0]), ":", str(x[1]) reactor.stop()
def set_event(x): w.total -= 1 assert w.total >= 0 if w.total == 0: reactor.stop()