Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Disabled logging task offers once a task is completed #4787

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion golem/task/taskrequestorstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def __init__(self):
def got_want_to_compute(self):
"""Makes note of a received work offer"""
self._want_to_compute_count += 1
logger.info('Received work offers: %r', self._want_to_compute_count)

def got_task_message(self, msg: TaskMsg, latest_status: TaskStatus):
"""Stores information from task level message"""
Expand Down Expand Up @@ -408,6 +407,9 @@ def on_message(self,
pass

elif op == TaskOp.WORK_OFFER_RECEIVED:
if task_state.status.is_active():
logger.info('Received work offers: %r',
self.tasks[task_id].want_to_compute_count())
self.tasks[task_id].got_want_to_compute()

elif op == TaskOp.RESTORED:
Expand Down
9 changes: 8 additions & 1 deletion tests/golem/task/test_taskrequestorstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ def test_stats_collection(self):
"about any subtasks")

# receive work offer
rs.on_message("task1", tstate, op=TaskOp.WORK_OFFER_RECEIVED)
with self.assertLogs(logger, level="INFO") as log:
rs.on_message("task1", tstate, op=TaskOp.WORK_OFFER_RECEIVED)
self.assertTrue(any("Received work offers"
in line for line in log.output))
# which does not mean that a subtask is in progress
cs = rs.get_current_stats()
self.assertEqual(cs, CurrentStats(1, 0, 0, 0, 0, 0, 0, 0, 1),
Expand Down Expand Up @@ -361,6 +364,10 @@ def test_stats_collection(self):
self.assertTrue(rs.is_task_finished("task1"),
"A task should be finished now")

# we should not log on received offers once the task is finished
with self.assertNoLogs(logger, level="INFO"):
rs.on_message("task1", tstate, op=TaskOp.WORK_OFFER_RECEIVED)

@staticmethod
def create_task_and_taskstate(rs, name):
tstate = TaskState()
Expand Down