def _wait_for_history(ctx, gi, history_id): def has_active_jobs(gi): if has_jobs_in_states(gi, history_id, ["new", "upload", "waiting", "queued", "running"]): return True else: return None wait_on(lambda: _retry_on_timeouts(ctx, gi, has_active_jobs), "active jobs", timeout=60 * 60 * 24) def state_func(): return _retry_on_timeouts(ctx, gi, lambda gi: gi.histories.show_history(history_id)) return _wait_on_state(state_func)
def wait_for_all_installed(self): def status_ready(repo): status = repo["status"] if status in ["Installing", "New"]: return None if status == "Installed": return True raise Exception("Error installing repo status is %s" % status) def ready(): repos = self.tool_shed_client.get_repositories() ready = all(map(status_ready, repos)) return ready or None wait_on(ready, "galaxy tool installation", timeout=60 * 60 * 1)
def _wait_on_state(state_func): def get_state(): response = state_func() state = response["state"] if str(state) not in ["running", "queued", "new", "ready"]: return state else: return None final_state = wait_on(get_state, "state", timeout=100) return final_state
def _wait_on_state(state_func, polling_backoff=0): def get_state(): response = state_func() state = response["state"] if str(state) not in ["running", "queued", "new", "ready"]: return state else: return None timeout = 60 * 60 * 24 final_state = wait_on(get_state, "state", timeout, polling_backoff) return final_state