parameters: (cmd, role, taskid, pass_env)
docstring: Execute the command line command.
docstring_summary: Execute the command line command.
docstring_tokens: Execute the command line command .
function: def exec_cmd(cmd, role, taskid, pass_env):
      """Execute the command line command."""
      if cmd[0].find('/') == -1 and os.path.exists(cmd[0]) and os.name != 'nt':
          cmd[0] = './' + cmd[0]
      cmd = ' '.join(cmd)
      env = os.environ.copy()
      for k, v in pass_env.items():
          env[k] = str(v)
  
      env['DMLC_TASK_ID'] = str(taskid)
      env['DMLC_ROLE'] = role
      env['DMLC_JOB_CLUSTER'] = 'local'
  
      num_retry = 0
      if 'DMLC_NUM_ATTEMPT' in env:
          num_retry = env['DMLC_NUM_ATTEMPT']
  
      while True:
          if os.name == 'nt':
              ret = subprocess.call(cmd, shell=True, env=env)
          else:
              ret = subprocess.call(cmd, shell=True, executable='bash', env=env)
          if ret == 0:
              logging.debug('Thread %d exit with 0', taskid)
              return
          else:
              num_retry -= 1
              if num_retry >= 0:
                  continue
              if os.name == 'nt':
                  sys.exit(-1)
              else:
                  raise RuntimeError('Get nonzero return code=%d' % ret)
function_tokens: def exec_cmd ( cmd , role , taskid , pass_env ) : if cmd [ 0 ] . find ( '/' ) == - 1 and os . path . exists ( cmd [ 0 ] ) and os . name != 'nt' : cmd [ 0 ] = './' + cmd [ 0 ] cmd = ' ' . join ( cmd ) env = os . environ . copy ( ) for k , v in pass_env . items ( ) : env [ k ] = str ( v ) env [ 'DMLC_TASK_ID' ] = str ( taskid ) env [ 'DMLC_ROLE' ] = role env [ 'DMLC_JOB_CLUSTER' ] = 'local' num_retry = 0 if 'DMLC_NUM_ATTEMPT' in env : num_retry = env [ 'DMLC_NUM_ATTEMPT' ] while True : if os . name == 'nt' : ret = subprocess . call ( cmd , shell = True , env = env ) else : ret = subprocess . call ( cmd , shell = True , executable = 'bash' , env = env ) if ret == 0 : logging . debug ( 'Thread %d exit with 0' , taskid ) return else : num_retry -= 1 if num_retry >= 0 : continue if os . name == 'nt' : sys . exit ( - 1 ) else : raise RuntimeError ( 'Get nonzero return code=%d' % ret )