def _poll_sensors_for_results(self, sensor_ids):
        """
        Main loop which polls sensor for results and detects dead sensors.
        """
        for sensor_id in sensor_ids:
            now = int(time.time())

            process = self._processes[sensor_id]
            status = process.poll()

            if status is not None:
                # Dead process detected
                LOG.info(
                    "Process for sensor %s has exited with code %s", sensor_id, status
                )

                sensor = self._sensors[sensor_id]
                self._delete_sensor(sensor_id)

                self._dispatch_trigger_for_sensor_exit(sensor=sensor, exit_code=status)

                # Try to respawn a dead process (maybe it was a simple failure which can be
                # resolved with a restart)
                concurrency.spawn(
                    self._respawn_sensor,
                    sensor_id=sensor_id,
                    sensor=sensor,
                    exit_code=status,
                )
            else:
                sensor_start_time = self._sensor_start_times[sensor_id]
                sensor_respawn_count = self._sensor_respawn_counts[sensor_id]
                successfully_started = (
                    now - sensor_start_time
                ) >= SENSOR_SUCCESSFUL_START_THRESHOLD

                if successfully_started and sensor_respawn_count >= 1:
                    # Sensor has been successfully running more than threshold seconds, clear the
                    # respawn counter so we can try to restart the sensor if it dies later on
                    self._sensor_respawn_counts[sensor_id] = 0

        Main loop which polls sensor for results and detects dead sensors.
        
st2reactor/st2reactor/container/process_container.py