def _schedule_callbacks(self, resp): callbacks = resp._registered_callbacks if not callbacks: return loop = get_running_loop() for cb, is_async in callbacks: if is_async: loop.create_task(cb()) else: loop.run_in_executor(None, cb)
def _schedule_callbacks(self, resp): callbacks = resp._registered_callbacks # PERF(vytas): resp._registered_callbacks is already checked directly # to shave off a function call since this is a hot/critical code path. # if not callbacks: # return loop = get_running_loop() for cb, is_async in callbacks: if is_async: loop.create_task(cb()) else: loop.run_in_executor(None, cb)
def __init__(self, file): self._file = file self._loop = get_running_loop()