Commit 9bf5e01f authored by Guido Trotter's avatar Guido Trotter
Browse files

_OpExecCallbacks abstract _AppendFeedback



Move some code to a decorated function rather than explicitely
acquiring/releasing the lock in AppendFeedback.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 41a26b68
......@@ -446,6 +446,15 @@ class _OpExecCallbacks(mcpu.OpExecCbBase):
finally:
self._queue.release()
@locking.ssynchronized(_big_jqueue_lock)
def _AppendFeedback(self, timestamp, log_type, log_msg):
"""Internal feedback append function, with locks
"""
self._job.log_serial += 1
self._op.log.append((self._job.log_serial, timestamp, log_type, log_msg))
self._queue.UpdateJobUnlocked(self._job, replicate=False)
def Feedback(self, *args):
"""Append a log entry.
......@@ -461,14 +470,7 @@ class _OpExecCallbacks(mcpu.OpExecCbBase):
# The time is split to make serialization easier and not lose
# precision.
timestamp = utils.SplitTime(time.time())
self._queue.acquire()
try:
self._job.log_serial += 1
self._op.log.append((self._job.log_serial, timestamp, log_type, log_msg))
self._queue.UpdateJobUnlocked(self._job, replicate=False)
finally:
self._queue.release()
self._AppendFeedback(timestamp, log_type, log_msg)
def ReportLocks(self, msg):
"""Write locking information to the job.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment