code: def poll_process(process_name):
      
      try:
          pid = get_process_pid(process_name)
          if pid is None:
              sys.stdout.write('PID file was not found. Process {0} is likely terminated.\n'.format(process_name))
              return False
  
          p = psutil.Process(pid)
          return_code = p.wait(timeout=0.01)
  
          if return_code is None:
              # process is already terminated
              sys.stdout.write('Process {0} is terminated \n'.format(process_name))
              return False
          else:
              # process is terminated; possibly by OS
              sys.stdout.write('Process {0} got terminated \n'.format(process_name))
              return False
      except TimeoutExpired:
          sys.stdout.write('Process {0} is alive and OK \n'.format(process_name))
          return True
docs: between killing a process and its actual termination lies poorly documented requirement -
          <purging process' io pipes and reading exit status>.
          this can be done either by os.wait() or process.wait()
          :return True if the process is alive and OK and False is the process was terminated