def __init__(self, max_workers=None, loop=None, maxtasks=None): self._loop = get_io_loop(loop) self._max_workers = min(max_workers or _DEFAULT_WORKERS, _MAX_WORKERS) self._greenlets = set() self._available = set() self._maxtasks = maxtasks self._queue = deque() self._shutdown = False self._shutdown_lock = threading.Lock()
def test_run_in_io_loop(self): event_loop = pulsar.get_io_loop() def simple(a, b): return a + b d = run_in_loop(event_loop, simple, 1, 2) self.assertIsInstance(d, Future) self.assertEqual(d._loop, event_loop) result = yield d self.assertEqual(result, 3) yield self. async .assertRaises(TypeError, run_in_loop, event_loop, simple, 1, 'a')
def test_run_in_io_loop(self): event_loop = pulsar.get_io_loop() def simple(a, b): return a + b d = run_in_loop(event_loop, simple, 1, 2) self.assertIsInstance(d, Future) self.assertEqual(d._loop, event_loop) result = yield d self.assertEqual(result, 3) yield self.async.assertRaises(TypeError, run_in_loop, event_loop, simple, 1, 'a')
def test_io_loop_tid(self): loop = pulsar.get_io_loop() self.assertTrue(loop) tid = yield loop_thread_id(loop) self.assertNotEqual(tid, current_thread().ident)
def test_io_loop(self): io_loop = pulsar.get_io_loop() loop = get_event_loop() self.assertTrue(io_loop) self.assertTrue(loop) self.assertNotEqual(loop, io_loop)