def start(self, job_id, job_tag):
        """
        Apply the 'start' action to the session object
        If the request can be accepted it modifies the relevant fields
        and sets the need_update member to notify that the stored
        document needs to be updated
        """
        now = int(time.time())
        time_since_last_start = now - self.doc.get('time_start', 0)

        if job_tag > self.session_tag:
            raise freezer_api_exc.BadDataFormat('requested tag value too high')

        if time_since_last_start <= self.doc.get('hold_off', 60):
            # session has been started not so long ago
            # tag increments are not allowed during hold_off
            if job_tag < self.session_tag:
                self.action_result = 'success'
                self.set_job_start(job_id, now)
                self.need_update = True
            else:
                self.action_result = 'hold-off'
                self.need_update = False
        elif time_since_last_start > self.doc.get('hold_off', 60):
            # out of hold_off window:
            #  - ok to trigger new action start (job_tag == session_tag)
            # if job_tag < session_tag client is probably out-of-sync
            if self.session_tag == job_tag:
                self.session_tag += 1
                self.doc['time_start'] = now
                self.doc['status'] = 'running'
                self.doc['result'] = ''
                self.action_result = 'success'
                self.set_job_start(job_id, now)
                self.need_update = True
            else:
                self.action_result = 'out-of-sync'
                self.need_update = False
dataset/ETHPy150Open openstack/freezer-api/freezer_api/api/v1/sessions.py/Session.start/original