def schedule_later(self, delay_in_seconds, callback, *args, context=None): fut = self._future(func(callback, *args)) self._scheduled_callback_futures.append(fut) self.call_later(delay_in_seconds, fut.set_result, None, context=context)
def _future(self, done_hook): """ Create a future object that calls the done_hook when it is awaited :param loop: :param function: :return: """ fut = self.create_future() fut.add_done_callback(func(self.unwrapper, function=done_hook)) return fut
def schedule_soon(self, callback, *args, context=None): fut = self._future(func(callback, *args)) self._scheduled_callback_futures.append(fut) self.call_soon(fut.set_result, None, context=context)