def test_shared_worker_pool_stop(self): with self.temporary_worker_pool() as worker_pool: executor = TraitsExecutor( worker_pool=worker_pool, context=self._context, event_loop=self._event_loop, ) executor.stop() self.wait_until_stopped(executor) # Check that the the shared worker pool is still usable. cf_future = worker_pool.submit(int) self.assertEqual(cf_future.result(), 0)
def test_run_until_success(self): # Trait fired, condition starts false but becomes true. executor = TraitsExecutor( context=MultithreadingContext(), event_loop=self._event_loop, ) # Case 1: condition true on second trait change event. future = submit_call(executor, slow_return) self.run_until( future, "state", condition=lambda future: future.done, ) self.assertTrue(future.done) # Case 2: condition true on the first trait firing. executor.stop() self.run_until( executor, "stopped", condition=lambda executor: executor.stopped, ) self.assertTrue(executor.stopped)