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

Commit

Permalink
- Replace list with set
Browse files Browse the repository at this point in the history
 - Remove running tasks before counting
  • Loading branch information
maaktweluit committed Apr 19, 2019
1 parent d7e7c72 commit b2915b6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions golem/task/taskkeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def __init__(
# ids of tasks that this node may try to compute
self.supported_tasks: typing.List[str] = []
# ids of tasks that are computing on this node
self.running_tasks: typing.List[str] = []
self.running_tasks: typing.Set[str] = set()
# results of tasks' support checks
self.support_status: typing.Dict[str, SupportStatus] = {}
# tasks that were removed from network recently, so they won't
Expand Down Expand Up @@ -526,10 +526,10 @@ def find_newest_node(self, node_id) -> typing.Optional[dt_p2p.Node]:
def check_max_tasks_per_owner(self, owner_key_id):
owner_task_set = self._get_tasks_by_owner_set(owner_key_id)

if len(owner_task_set) <= self.max_tasks_per_requestor:
return
not_running = owner_task_set - self.running_tasks

not_running = [x for x in owner_task_set if x not in self.running_tasks]
if len(not_running) <= self.max_tasks_per_requestor:
return

by_age = sorted(not_running,
key=lambda tid: self.last_checking[tid])
Expand Down Expand Up @@ -655,7 +655,7 @@ def get_unsupport_reasons(self):
return ret

def task_started(self, task_id):
self.running_tasks.append(task_id)
self.running_tasks.add(task_id)

def task_ended(self, task_id):
try:
Expand Down

0 comments on commit b2915b6

Please # to comment.