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

Commit

Permalink
Call RTM in _react_to_cannot_compute_task() (#4992)
Browse files Browse the repository at this point in the history
  • Loading branch information
maaktweluit authored and mfranciszkiewicz committed Dec 13, 2019
1 parent b0e075c commit c5166ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
8 changes: 7 additions & 1 deletion golem/task/requestedtaskmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,13 @@ def _finish_subtask(self, subtask: RequestedSubtask, op: SubtaskOp):
)
update_provider_efficacy(node_id, op)
if subtask_timeout is not None:
update_provider_efficiency(node_id, subtask_timeout, comp_time)
if comp_time:
update_provider_efficiency(node_id, subtask_timeout, comp_time)
else:
logger.warning(
"Could not obtain computation time for subtask: %r",
subtask_id
)
dispatcher.send(
signal='golem.subtask',
event='finished',
Expand Down
24 changes: 14 additions & 10 deletions golem/task/tasksession.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import time
from typing import (
Any, Callable, TYPE_CHECKING,
Optional, Generator, Type
Optional, Generator
)

from ethereum.utils import denoms
Expand Down Expand Up @@ -43,7 +43,6 @@
from golem.task.requestedtaskmanager import ComputingNodeDefinition
from golem.task.rpc import add_resources
from golem.task.server import helpers as task_server_helpers
from golem.task.taskbase import Task

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
Expand Down Expand Up @@ -710,6 +709,7 @@ def _check_resource_size(self, resource_size):
return False
return True

@defer.inlineCallbacks
def _react_to_cannot_compute_task(self, msg):
if not self.check_provider_for_subtask(msg.task_id, msg.subtask_id):
self.dropped()
Expand All @@ -721,14 +721,18 @@ def _react_to_cannot_compute_task(self, msg):
msg.reason,
)

config = self.task_server.config_desc
timeout = config.computation_cancellation_timeout

self.task_manager.task_computation_cancelled(
msg.subtask_id,
msg.reason,
timeout,
)
if self.requested_task_manager.subtask_exists(msg.subtask_id):
yield deferred_from_future(
self.requested_task_manager.abort_subtask(msg.subtask_id)
)
else:
config = self.task_server.config_desc
timeout = config.computation_cancellation_timeout
self.task_manager.task_computation_cancelled(
msg.subtask_id,
msg.reason,
timeout,
)

@history.provider_history
def _react_to_cannot_assign_task(self, msg):
Expand Down
2 changes: 2 additions & 0 deletions tests/golem/task/test_tasksession.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def test_cannot_compute_task_computation_failure(self):
ts2 = self._get_requestor_tasksession()
ts2.task_manager.get_node_id_for_subtask.return_value = ts2.key_id
ts2.requested_task_manager.get_node_id_for_subtask.return_value = None
ts2.requested_task_manager.subtask_exists.return_value = False
ts2._react_to_cannot_compute_task(message.tasks.CannotComputeTask(
reason=message.tasks.CannotComputeTask.REASON.WrongCTD,
task_to_compute=None,
Expand All @@ -283,6 +284,7 @@ def test_cannot_compute_task_cancelled(self):
)
ts.task_manager.get_node_id_for_subtask.return_value = ts.key_id
ts.requested_task_manager.get_node_id_for_subtask.return_value = None
ts.requested_task_manager.subtask_exists.return_value = False
ts._react_to_cannot_compute_task(msg)
ts.task_manager.task_computation_cancelled.assert_called_once_with(
msg.subtask_id,
Expand Down

0 comments on commit c5166ad

Please sign in to comment.