Beispiel #1
0
 def __init__(self,
              endpoint,
              pubsub_endpoint,
              check_delay,
              ssh_server=None,
              **config):
     self.daemon = True
     self.config = config
     self.active = to_bool(config.get('active', True))
     self.context = zmq.Context()
     self.pubsub_endpoint = pubsub_endpoint
     self.endpoint = endpoint
     self.check_delay = check_delay
     self.ssh_server = ssh_server
     self.loop = ioloop.IOLoop()
     self._id = uuid.uuid4().hex  # XXX os.getpid()+thread id is enough...
     self.running = False
Beispiel #2
0
    def test_socketstats(self):
        if TRAVIS:
            return

        endpoint = util.DEFAULT_ENDPOINT_DEALER
        pubsub = util.DEFAULT_ENDPOINT_SUB
        statspoint = util.DEFAULT_ENDPOINT_STATS

        loop = ioloop.IOLoop()
        streamer = _StatsStreamer(endpoint, pubsub, statspoint, loop=loop)

        # now the stats collector
        self._collector = SocketStatsCollector(streamer,
                                               'sockets',
                                               callback_time=0.1,
                                               io_loop=loop)

        self._collector.start()
        loop.add_callback(streamer._init)

        # events
        def _events():
            msg = 'one.spawn.two', json.dumps({'process_pid': 187})
            for i in range(5):
                streamer.handle_recv(msg)

        events = ioloop.DelayedCallback(_events, 500, loop)
        events.start()

        def _stop():
            self._collector.stop()
            streamer.stop()

        stopper = ioloop.DelayedCallback(_stop, 500, loop)
        stopper.start()
        streamer.start()

        # let's see what we got
        try:
            self.assertTrue(len(streamer.msgs) > 1)
        finally:
            streamer.stop()
Beispiel #3
0
    def run(self):
        qstream = {'stream': self.stream}
        old_environ = os.environ
        old_paths = sys.path[:]
        try:
            sys.path = ['XYZ']
            os.environ = {'COCONUTS': 'MIGRATE'}
            cmd = ('%s -c "import sys; '
                   'sys.stdout.write(\':\'.join(sys.path)); '
                   ' sys.stdout.flush()"') % sys.executable

            self.loop = ioloop.IOLoop()
            self.watcher = Watcher('xx',
                                   cmd,
                                   copy_env=True,
                                   copy_path=True,
                                   stdout_stream=qstream,
                                   loop=self.loop,
                                   **self.kw)
            self.watcher.start()
            self.loop.start()
        finally:
            os.environ = old_environ
            sys.path[:] = old_paths
Beispiel #4
0
 def __init__(self, streamer):
     Thread.__init__(self)
     self.streamer = streamer
     self.loop = ioloop.IOLoop()
     self.daemon = True