def method(*args, **kwargs): exception = None try: if not unlocked: self.lock.acquire(1) #record all calls to clock.now() self.obj._clock = RecordClock() thread_ident = thread.get_ident() action = Action(thread_ident, name, datetime.now(), args, kwargs) system = None if not readonly: self.publisher.publish_before(action) try: system = action.execute_action(self.obj) except Exception as e: logger.debug(CORE_LOG_PREFIX + 'Error: ' + str(e)) if abort_exception: logger.debug(CORE_LOG_PREFIX + 'Aborting action' + str(action)) if not abort_exception: self.publisher.publish_exception(action) exception = e #restore clock action.results = self.obj._clock.results if not readonly and not abort_exception: self.publisher.publish(action) finally: if not unlocked: self.lock.release() if exception: raise exception return system