Skip to content
Snippets Groups Projects
Commit 100b0833 authored by Thomas Juerges's avatar Thomas Juerges
Browse files

Add function that tries to query for hanging requests only

parent 98bb1131
No related branches found
No related tags found
No related merge requests found
......@@ -186,6 +186,32 @@ def get_progress(status=None, exclude=False, only_last24h=False):
requests = all_requests
return requests
def get_stuck_requests(min_retries = 3, days_without_activity = 30):
try:
p = proxy.LtaStager.getprogress(True, 0)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
stuck = {}
for request_id, request_stats in p.items():
if request_stats['Status'] != 'aborted' and int(request_stats['Retries']) >= min_retries:
pending = get_surls_pending(int(request_id))
request_stats['Pending surls'] = pending
token = get_srm_token(int(request_id))
request_stats['SRM token'] = token
if days_without_activity is None or 'Latest success' not in request_stats.keys():
request_stats['Pending since'] = "Cannot be determined"
stuck[request_id] = request_stats
else:
dt = datetime.datetime.strptime(request_stats['Latest success'], '%Y-%m-%d %H:%M:%S.%f')
if datetime.datetime.now() - dt > datetime.timedelta(hours = 24 * days_without_activity):
request_stats['Pending since'] = dt
stuck[request_id] = request_stats
if stuck:
prettyprint(stuck)
else:
print('Nothing found, all running requests are OK.')
def reschedule_on_status(status=None):
""" Reschedule requests that have a status "on hold" or "aborted".
:param status: The status that a request has to have in order to be
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment