def test_pool_6(self): pool = Pool(name='test6') assert pool.name == 'test6' assert pool.size == cpu_count() try: result = yield pool.on_ready(timeout=5) except Exception as e: result = e assert result is pool assert pool.get_number_of_workers() == pool.size d = pool.apply_async('math.sqrt', (16, ), timeout=5) d.cancel() try: result = yield d except Exception as e: result = e assert isinstance(result, CancelledError) try: result = yield pool.close(timeout=5) except Exception as e: result = e assert result is pool assert pool.get_number_of_workers() == 0
def test_pool_9(): pool = Pool(name='test9', init_call='math.sqrt', init_args=(-1,)) assert pool.name == 'test9' assert pool.size == cpu_count() try: result = yield pool.on_ready(timeout=5) except Exception as e: result = e assert result is pool assert pool.get_number_of_workers() == pool.size # This will timeout as we haven't called "close". try: result = yield pool.on_closure(timeout=2) except Exception as e: result = e assert isinstance(result, PoolTimeout) # This will timeout. Since the init_call's failed, the pool will # collapse (all of the processes will end due to an initialization # error and will not be replaced), and will never fire "on_ready" # again. try: result = yield pool.on_ready(timeout=2) except Exception as e: result = e assert isinstance(result, PoolTimeout) assert pool.get_number_of_workers() == 0
def test_pool_1(): pool = Pool(name='test1') assert pool.name == 'test1' assert pool.size == cpu_count() try: result = yield pool.on_ready(timeout=5) except Exception, e: result = e
def test_pool_9(): pool = Pool(name='test9', init_call='math.sqrt', init_args=(-1,)) assert pool.name == 'test9' assert pool.size == cpu_count() try: result = yield pool.on_ready(timeout=5) except Exception, e: result = e
def test_pool_9(): pool = Pool(name='test9', init_call='math.sqrt', init_args=(-1, )) assert pool.name == 'test9' assert pool.size == cpu_count() try: result = yield pool.on_ready(timeout=5) except Exception, e: result = e
def test_pool_1(self): pool = Pool(name='test1') assert pool.name == 'test1' assert pool.size == cpu_count() try: result = yield pool.on_ready(timeout=5) except Exception as e: result = e assert result is pool assert pool.get_number_of_workers() == pool.size directory = (os.path.dirname(__file__), ) dirs = (directory, ) * 4 calls = ('os.path.exists', 'os.path.isdir', 'os.path.isfile', 'os.path.islink') results = yield gatherResults(map(pool.apply_async, calls, dirs)) exists, isdir, isfile, islink = results assert exists is True assert isdir is True assert isfile is False assert islink is False try: result = yield pool.apply_async('math.sqrt', (-1, ), timeout=5) except Exception as e: result = e assert isinstance(result, ValueError) try: result = yield pool.apply_async(os.path.isdir, directory, timeout=5) except Exception as e: result = e assert result is True try: result = yield pool.close(timeout=5) except Exception as e: result = e assert result is pool assert pool.get_number_of_workers() == 0
def test_pool_7(self): pool = Pool(name='test7') assert pool.name == 'test7' assert pool.size == cpu_count() try: result = yield pool.on_ready(timeout=5) except Exception as e: result = e assert result is pool assert pool.get_number_of_workers() == pool.size # Try using keyword arguments. result = yield pool.apply_async(int, ('1010', ), dict(base=2)) assert result == 10 pool.close() # Try "apply_async" after closing. try: result = yield pool.apply_async(int, ('1011', ), dict(base=2)) except Exception as e: result = e assert isinstance(result, PoolError) # Try "on_ready" after closing. try: result = yield pool.on_ready(timeout=5) except Exception as e: result = e assert isinstance(result, PoolError) try: result = yield pool.on_closure(timeout=5) except Exception as e: result = e assert result is pool assert pool.get_number_of_workers() == 0 # Call again after pool has closed. try: result = yield pool.on_closure() except Exception as e: result = e assert result is pool