code: def _poll_process(self, box_config):
          
          try:
              p = psutil.Process(box_config.pid)
  
              return_code = p.wait(timeout=0.01)
              if return_code is None:
                  # process is already terminated
                  self.logger.info('Process {0} is terminated'.format(box_config.process_name))
                  return
              else:
                  # process is terminated; possibly by OS
                  box_config.pid = None
                  self.bc_dao.update(box_config)
                  self.logger.info('Process {0} got terminated. Cleaning up'.format(box_config.process_name))
          except TimeoutExpired:
              # process is alive and OK
              pass
          except Exception:
              self.logger.error('Exception on polling: {0}'.format(box_config.process_name), exc_info=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()