Example #1
0
class Container(object):
    def __init__(self, *handlers, **kwargs):
        self.tornado_loop = kwargs.get('loop',
                                       tornado.ioloop.IOLoop.instance())
        kwargs['global_handler'] = TornadoLoopHandler(
            self.tornado_loop, kwargs.get('handler_base', None))
        self.container = BaseContainer(*handlers, **kwargs)

    def initialise(self):
        self.container.start()
        self.container.process()

    def run(self):
        self.initialise()
        self.tornado_loop.start()

    def stop(self):
        self.container.stop()

    def touch(self):
        self._process()

    def _process(self):
        self.container.process()
        if not self.container.quiesced:
            self.tornado_loop.add_callback(self._process)
Example #2
0
class Container(object):
    def __init__(self, *handlers, **kwargs):
        self.tornado_loop = kwargs.get('loop', tornado.ioloop.IOLoop.instance())
        kwargs['global_handler'] = TornadoLoopHandler(self.tornado_loop, kwargs.get('handler_base', None))
        self.container = BaseContainer(*handlers, **kwargs)

    def initialise(self):
        self.container.start()
        self.container.process()

    def run(self):
        self.initialise()
        self.tornado_loop.start()

    def touch(self):
        self._process()

    def _process(self):
        self.container.process()
        if not self.container.quiesced:
            self.tornado_loop.add_callback(self._process)