<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _process_terminal_state(self, freerun_entry, uow, flow_request=None):
 """ method that takes care of processing unit_of_work records in STATE_PROCESSED, STATE_NOOP, STATE_INVALID, STATE_CANCELED states"""

        msg = 'UOW for {0} found in state {1}.'.format(freerun_entry.schedulable_name, uow.state)
        self._log_message(INFO, freerun_entry, msg)
        self.insert_and_publish_uow(freerun_entry, flow_request, reset_uow=True)