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

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: maaktweluit <10008353+maaktweluit@users.noreply.github.com>
  • Loading branch information
mfranciszkiewicz and maaktweluit committed Jun 17, 2019
1 parent 6594a8f commit e744b63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions golem/task/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,12 @@ def enqueue_new_task(client, task, force=False) \

def _create_task_error(e, _self, task_dict, **_kwargs) \
-> typing.Tuple[None, typing.Union[str, typing.Dict]]:
logger.error("Cannot create task %r: %s", task_dict, e)
_self.client.task_manager.task_creation_failed(task_dict.get('id'), str(e))

if hasattr(e, 'to_dict'):
temp_dict = rpc_utils.int_to_string(e.to_dict())
return None, temp_dict

_self.client.task_manager.task_creation_failed(task_dict.get('id'), str(e))
return None, str(e)


Expand Down
11 changes: 6 additions & 5 deletions golem/task/taskmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def create_task(self, dictionary, minimal=False):
task = builder_type(self.node, definition, self.dir_manager).build()
task_id = task.header.task_id

logger.info("Creating task %r (%s)", type(task), task_id)
logger.info("Creating task. type=%r, id=%s", type(task), task_id)
self.tasks[task_id] = task
self.tasks_states[task_id] = TaskState(task)
return task
Expand All @@ -205,8 +205,7 @@ def add_new_task(self, task: Task, estimated_fee: int = 0) -> None:
self.tasks_states[task_id] = task_state

if task_state.status is not TaskStatus.creating:
raise RuntimeError("Task {} has already been added"
.format(task.header.task_id))
raise RuntimeError("Task {} has already been added".format(task_id))

task.header.task_owner = self.node
self.sign_task_header(task.header)
Expand All @@ -226,6 +225,8 @@ def add_new_task(self, task: Task, estimated_fee: int = 0) -> None:
persist=False)

def task_creation_failed(self, task_id: str, reason: str) -> None:
logger.error("Cannot create task. id=%s : %s", task_id, reason)

if task_id in self.tasks_states:
task_state = self.tasks_states[task_id]
task_state.status = TaskStatus.errorCreating
Expand Down Expand Up @@ -377,7 +378,7 @@ def restore_tasks(self) -> None:
def resources_send(self, task_id):
self.tasks_states[task_id].status = TaskStatus.waiting
self.notice_task_updated(task_id)
logger.info("Resources for task %s sent", task_id)
logger.info("Resources for task sent. id=%s", task_id)

def got_wants_to_compute(self,
task_id: str):
Expand Down Expand Up @@ -714,7 +715,7 @@ def get_trust_mod(self, subtask_id):
task_id = self.subtask2task_mapping[subtask_id]
return self.tasks[task_id].get_trust_mod(subtask_id)

logger.error("This is not my subtask %s", subtask_id)
logger.error("This is not my subtask. id=%s", subtask_id)
return 0

def update_task_signatures(self):
Expand Down

0 comments on commit e744b63

Please sign in to comment.