def StartFlowAndWorker(client_id, flow_name, **kwargs):
 queue = rdfvalue.RDFURN(('DEBUG-%s-' % getpass.getuser()))
 if ('token' in kwargs):
  token = kwargs.pop('token')
 else:
  token = access_control.ACLToken(username='GRRConsole')
 session_id = flow.GRRFlow.StartFlow(client_id=client_id, flow_name=flow_name, queue=queue, token=token, **kwargs)
 worker_thrd = worker.GRRWorker(queues=[queue], token=token, threadpool_size=1)
 while True:
  try:
   worker_thrd.RunOnce()
  except KeyboardInterrupt:
   print 'exiting'
   worker_thrd.thread_pool.Join()
   break
  time.sleep(2)
  with aff4.FACTORY.Open(session_id, token=token) as flow_obj:
   if (not flow_obj.GetRunner().IsRunning()):
    break
 worker_thrd.thread_pool.Join()
 return session_id

def StartFlowAndWorker ( client_id , flow_name , ** kwargs ) : queue = rdfvalue . RDFURN ( ( 'DEBUG-%s-' % getpass . getuser ( ) ) ) if ( 'token' in kwargs ) : token = kwargs . pop ( 'token' ) else : token = access_control . ACLToken ( username = 'GRRConsole' ) session_id = flow . GRRFlow . StartFlow ( client_id = client_id , flow_name = flow_name , queue = queue , token = token , ** kwargs ) worker_thrd = worker . GRRWorker ( queues = [ queue ] , token = token , threadpool_size = 1 ) while True : try : worker_thrd . RunOnce ( ) except KeyboardInterrupt : print 'exiting' worker_thrd . thread_pool . Join ( ) break time . sleep ( 2 ) with aff4 . FACTORY . Open ( session_id , token = token ) as flow_obj : if ( not flow_obj . GetRunner ( ) . IsRunning ( ) ) : break worker_thrd . thread_pool . Join ( ) return session_id
launches the flow and worker and waits for it to finish .