'Persist stack state to database and release stack lock'

def persist_state_and_release_lock(self, engine_id):

    if (self.id is None):
        return
    stack = stack_object.Stack.get_by_id(self.context, self.id, eager_load=False)
    if (stack is not None):
        values = {'action': self.action, 'status': self.status, 'status_reason': six.text_type(self.status_reason)}
        self._send_notification_and_add_event()
        stack.persist_state_and_release_lock(self.context, self.id, engine_id, values)
