def _get_isactive_stopper(self, name):
"""
Return a boolean determining if a task is active and its cancel/stop method if the task is registered.
"""
task = self._pending_tasks.get(name, None)
def do_get(task):
if isinstance(task, Deferred):
# Have in mind that any deferred in the pending tasks list should have been constructed with a
# canceller function.
return not task.called, getattr(task, 'cancel', None)
elif isinstance(task, DelayedCall):
return task.active(), task.cancel
elif isinstance(task, LoopingCall):
return task.running, task.stop
elif isinstance(task, tuple):
if task[0].active():
return task[0].active(), task[0].cancel
else:
return do_get(task[1])
else:
return False, None
return do_get(task)
评论列表
文章目录