Пример #1
0
 def run_task_and_exit():
     #for i in xrange(1000):
     for i in xrange(100040):
         w.total += 1
         df = launch_coroutine(wrap_task(reactor.callLater),
                               w.do_some_things)
         df.addCallback(set_event)
         df.addErrback(set_event_error)
Пример #2
0
 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)
Пример #3
0
 def run_task_and_exit():
     #for i in xrange(1000):
     for i in xrange(100040):
         w.total += 1
         df = launch_coroutine(wrap_task(reactor.callLater),
                               w.do_some_things)
         df.addCallback(set_event)
         df.addErrback(set_event_error)
Пример #4
0
 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)
Пример #5
0
    def parse_allowed(self):
        if self.parse_pending:
            return
        self.parse_pending = True

        df = ThreadedDeferred(wrap_task(self.rawserver.external_add_task),
                              self._parse_allowed, daemon=True)
        def eb(etup):
            self.parse_pending = False
            self._print_exc("parse_dir: ", etup)
        df.addCallbacks(self._parse_allowed_finished, eb)
Пример #6
0
    def __init__(self, traverser):
        NATBase.__init__(self)

        self.controlURL = None
        self.transport = None
        self.traverser = traverser
        self.rawserver = traverser.rawserver

        # this service can only be provided if rawserver supports multicast
        if not hasattr(self.rawserver, "create_multicastsocket"):
            raise AttributeError(
                "RawServer does not support create_multicastsocket!")

        reactor.callFromThread(launch_coroutine, wrap_task(reactor.callLater),
                               self.begin_discovery)
Пример #7
0
    def __init__(self, traverser):
        NATBase.__init__(self)

        self.controlURL = None
        self.transport = None
        self.traverser = traverser
        self.rawserver = traverser.rawserver

        # this service can only be provided if rawserver supports multicast
        if not hasattr(self.rawserver, "create_multicastsocket"):
            raise AttributeError("RawServer does not support create_multicastsocket!")
               
        reactor.callFromThread(launch_coroutine,
                               wrap_task(reactor.callLater),
                               self.begin_discovery)
Пример #8
0
    def save_dfile(self):
        if self.save_pending:
            return
        self.save_pending = True

        # if this is taking all the time, threading it won't help anyway because
        # of the GIL
        #state = bencode(self.state)
        state = cPickle.dumps(self.state) # pickle handles Unicode.

        df = ThreadedDeferred(wrap_task(self.rawserver.external_add_task),
                              self._save_dfile, state)
        def cb(r):
            self.save_pending = False
            if NOISY:
                self._print_event( "save_dfile: Completed" )
        def eb(etup):
            self.save_pending = False
            self._print_exc( "save_dfile: ", etup )
        df.addCallbacks(cb, eb)