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()