def run(self): collector = SocketStatsCollector(streamer, 'sockets', callback_time=0.1, io_loop=self.loop) collector.start() self.loop.start()
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()