parameters: (arg1, arg2)
docstring: Stops a proces that contains arg1 and is filtered by arg2
docstring_summary: Stops a proces that contains arg1 and is filtered by arg2
docstring_tokens: Stops a proces that contains arg1 and is filtered by arg2
function: def kill(arg1, arg2):
      """Stops a proces that contains arg1 and is filtered by arg2
      """
      from subprocess import Popen, PIPE
  
      # Wait until ready
      t0 = time.time()
      # Wait no more than these many seconds
      time_out = 30
      running = True
  
      while running and time.time() - t0 < time_out:
          if os.name == 'nt':
              p = Popen(f'tasklist | find "{arg1}"', shell=True,
                        stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
          else:
              p = Popen(f'ps aux | grep {arg1}', shell=True,
                        stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
  
          lines = p.stdout.readlines()
  
          running = False
          for line in lines:
              # this kills all java.exe and python including self in windows
              if (f'{arg2}' in str(line)) or (os.name == 'nt' and f'{arg1}' in str(line)):
                  running = True
  
                  # Get pid
                  fields = line.strip().split()
  
                  info(f'Stopping {arg1} (process number {int(fields[1])})')
                  if os.name == 'nt':
                      kill = f'taskkill /F /PID "{int(fields[1])}"'
                  else:
                      kill = f'kill -9 {int(fields[1])} 2> /dev/null'
                  os.system(kill)
  
          # Give it a little more time
          time.sleep(1)
  
      if running:
          _procs = '\n'.join([str(_l).strip() for _l in lines])
          raise Exception(f"Could not stop {arg1}: "
                          f"Running processes are\n{_procs}")
function_tokens: def kill ( arg1 , arg2 ) : from subprocess import Popen , PIPE # Wait until ready t0 = time . time ( ) # Wait no more than these many seconds time_out = 30 running = True while running and time . time ( ) - t0 < time_out : if os . name == 'nt' : p = Popen ( f'tasklist | find "{arg1}"' , shell = True , stdin = PIPE , stdout = PIPE , stderr = PIPE , close_fds = False ) else : p = Popen ( f'ps aux | grep {arg1}' , shell = True , stdin = PIPE , stdout = PIPE , stderr = PIPE , close_fds = True ) lines = p . stdout . readlines ( ) running = False for line in lines : # this kills all java.exe and python including self in windows if ( f'{arg2}' in str ( line ) ) or ( os . name == 'nt' and f'{arg1}' in str ( line ) ) : running = True # Get pid fields = line . strip ( ) . split ( ) info ( f'Stopping {arg1} (process number {int(fields[1])})' ) if os . name == 'nt' : kill = f'taskkill /F /PID "{int(fields[1])}"' else : kill = f'kill -9 {int(fields[1])} 2> /dev/null' os . system ( kill ) # Give it a little more time time . sleep ( 1 ) if running : _procs = '\n' . join ( [ str ( _l ) . strip ( ) for _l in lines ] ) raise Exception ( f"Could not stop {arg1}: " f"Running processes are\n{_procs}" )