Skip to content

Commit

Permalink
Merge pull request #604 from NCATSTranslator/revert-603-timedout_merg…
Browse files Browse the repository at this point in the history
…e_handling

Revert "added a condition for merged mesg timeout"
  • Loading branch information
ShervinAbd92 authored Mar 20, 2024
2 parents b783167 + eae95e6 commit c98083a
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions tr_sys/tr_ars/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,30 +190,17 @@ def catch_timeout_async():
logging.info(f'Checking timeout at {now}')
time_threshold = now - timezone.timedelta(minutes=10)
max_time = time_threshold+timezone.timedelta(minutes=5)
merge_timedelta = timezone.timedelta(minutes=8)

messages = Message.objects.filter(timestamp__gt=time_threshold,timestamp__lt=max_time, status__in='R').values_list('actor','id','timestamp','updated_at')
for mesg in messages:
mpk=mesg[0]
id = mesg[1]
actor = Agent.objects.get(pk=mpk)
timestamp=mesg[2]
updated_at=mesg[3]
logging.info(f'actor: {actor} id: {mesg[1]} timestamp: {mesg[2]} updated_at {mesg[3]}')

#exempting parents from timing out
if actor.name == 'ars-default-agent':
continue
elif actor.name == 'ars-ars-agent':
timedelta = updated_at - timestamp
if timedelta > merge_timedelta:
logging.info('merge_agent pk: %s has been running more than 8 min, setting its code to 598')
message = get_object_or_404(Message.objects.filter(pk=mesg[1]))
message.code = 598
message.status = 'E'
message.save(update_fields=['status','code'])
else:
continue
else:
logging.info(f'for actor: {actor.name}, and pk {str(id)} the status is still "Running" after 5 min, setting code to 598')
message = get_object_or_404(Message.objects.filter(pk=mesg[1]))
Expand Down

0 comments on commit c98083a

Please sign in to comment.