def __init__(self, allow_app_replacement=False): assert (allow_app_replacement or runtime.current_app is None ), "Only one Application instance per program allowed" runtime.current_app = self self.hub = EventHub() self.waits = WaitPool() self._run = False self._services = [] self._loops = [] self.running = set()
class TestWaitPoolWithEarlyReturn(object): def setup(self): self.pool = WaitPool() self.who = Who() self.waiter = EarlyReadyWaiter() self.result = self.pool.wait(self.who, self.waiter) def test_results_is_EarlyValue(self): assert isinstance(self.result, EarlyValue) assert self.result.val == "foo" def test_waiter_wait_id_not_added_to_wait_pool(self): assert self.waiter.wait_id not in self.pool.waits def test_who_not_added_to_wait_pool(self): assert self.who not in self.pool.loop_refs
class TestWaitPoolWithStringWaiter(object): def setup(self): self.pool = WaitPool() self.who = Who() self.wait_for = "a string" self.result = self.pool.wait(self.who, self.wait_for) def test_the_waiting_entity_is_added_to_wait_pool(self): assert self.pool.waits[self.wait_for] w = self.pool.waits[self.wait_for].pop() assert w is self.who def test_StringWaiter_added_to_wait_pool(self): v = self.pool.loop_refs[self.who].pop() assert isinstance(v, StringWaiter) def test_result_is_wait_id(self): assert self.result == self.wait_for
def setup(self): self.pool = WaitPool() self.who = Who() self.wait_for = "a string" self.result = self.pool.wait(self.who, self.wait_for)
def setup(self): self.pool = WaitPool() self.who = Who() self.waiter = EarlyReadyWaiter() self.result = self.pool.wait(self.who, self.waiter)