def WakeStuckFlow(session_id):
 session_id = rdfvalue.SessionID(session_id)
 woken = 0
 checked_pending = False
 with queue_manager.QueueManager() as manager:
  for (request, responses) in manager.FetchRequestsAndResponses(session_id):
   if (not checked_pending):
    task = manager.Query(request.client_id, task_id=('task:%s' % request.request.task_id))
    if task:
     return
    checked_pending = True
   if ((not responses) or (responses[(-1)].type != rdf_flows.GrrMessage.Type.STATUS)):
    manager.QueueClientMessage(request.request)
    woken += 1
   if (responses and (responses[(-1)].type == rdf_flows.GrrMessage.Type.STATUS)):
    manager.QueueNotification(session_id)
 return woken

def WakeStuckFlow ( session_id ) : session_id = rdfvalue . SessionID ( session_id ) woken = 0 checked_pending = False with queue_manager . QueueManager ( ) as manager : for ( request , responses ) in manager . FetchRequestsAndResponses ( session_id ) : if ( not checked_pending ) : task = manager . Query ( request . client_id , task_id = ( 'task:%s' % request . request . task_id ) ) if task : return checked_pending = True if ( ( not responses ) or ( responses [ ( - 1 ) ] . type != rdf_flows . GrrMessage . Type . STATUS ) ) : manager . QueueClientMessage ( request . request ) woken += 1 if ( responses and ( responses [ ( - 1 ) ] . type == rdf_flows . GrrMessage . Type . STATUS ) ) : manager . QueueNotification ( session_id ) return woken
wake up stuck flows .