@classmethod
    def contemplate_termination(cls, thread_count_mod=0):
        """
        Looks at how long it's been since this worker has done something, and
        decides whether to self-terminate.
        
        :param int thread_count_mod: Add this to the amount returned by the call
            to :py:meth:`get_num_active_threads`. This is useful when calling
            this method from a non-encoder thread.
        :rtype: bool
        :returns: ``True`` if this instance terminated itself, ``False``
            if not.
        """
        if not cls.is_ec2_instance():
            # Developing locally, don't go here.
            return False

        # This is -1 since this is also a thread doing the contemplation.
        # This would always be 1, even if we had no jobs encoding, if we
        # didn't take into account this thread.
        num_active_threads = cls.get_num_active_threads() + thread_count_mod

        if num_active_threads > 0:
            # Encoding right now, don't terminate.
            return False

        tdelt = datetime.datetime.now() - cls.last_dtime_i_did_something
        # Total seconds of inactivity.
        inactive_secs = total_seconds(tdelt)

        # If we're over the inactivity threshold...
        if settings.NOMMERD_MAX_INACTIVITY > inactive_secs:
            instance_id = cls.get_instance_id()
            conn = cls._aws_ec2_connection()
            # Find this particular EC2 instance via boto.
            reservations = conn.get_all_instances(instance_ids=[instance_id])
            # This should only be one match, but in the interest of
            # playing along...
            for reservation in reservations:
                for instance in reservation.instances:
                    # Here's the instance, terminate it.
                    logger.info("Goodbye, cruel world.")
                    cls.send_instance_state_update(state='TERMINATED')
                    instance.terminate()
            # Seeya later!
            return True
        # Continue existence, no termination.
        return False
dataset/ETHPy150Open duointeractive/media-nommer/media_nommer/ec2nommerd/node_state.py/NodeStateManager.contemplate_termination/swapped operands of `>`