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

Fix: execute _resource_downloaded on successful resource download #4927

Merged
merged 2 commits into from
Nov 27, 2019
Merged
Changes from 1 commit
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
35 changes: 27 additions & 8 deletions golem/task/taskserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ def task_given(
task_header.subtask_budget, msg.want_to_compute_task.price)
self.task_computer.task_given(msg.compute_task_def, cpu_time_limit)

resource_downloaded = functools.partial(
self._resource_downloaded,
msg.subtask_id,
msg.requestor_id,
msg.price)

if task_header.environment_prerequisites:
subtask_inputs_dir = self.task_computer.get_subtask_inputs_dir()
resources_options = msg.resources_options or dict()
Expand All @@ -516,26 +522,39 @@ def task_given(
) for resource_id in msg.compute_task_def['resources']
]

defer.gatherResults(deferred_list, consumeErrors=True)\
.addCallbacks(
lambda _: self.resource_collected(msg.task_id),
lambda e: self.resource_failure(msg.task_id, e))
defer.gatherResults(
deferred_list,
consumeErrors=True,
).addCallback(
lambda _: resource_downloaded()
).addCallbacks(
lambda _: self.resource_collected(msg.task_id),
lambda e: self.resource_failure(msg.task_id, e))
else:
self.request_resource(
msg.task_id,
msg.subtask_id,
msg.compute_task_def['resources'],
msg.resources_options,
)
resource_downloaded()

return True

def _resource_downloaded(
self,
subtask_id: str,
requestor_id: str,
price: int,
) -> None:
self.requested_tasks.clear()
update_requestor_assigned_sum(msg.requestor_id, msg.price)
update_requestor_assigned_sum(requestor_id, price)
dispatcher.send(
signal='golem.subtask',
event='started',
subtask_id=msg.subtask_id,
price=msg.price,
subtask_id=subtask_id,
price=price,
)
return True

def resource_collected(self, task_id: str) -> bool:
if self.task_computer.assigned_task_id != task_id:
Expand Down