(self, peer)
| 115 | |
| 116 | # Returns the next free or less worked task |
| 117 | def getTask(self, peer): |
| 118 | # Sort tasks by priority and worker numbers |
| 119 | self.tasks.sort(key=lambda task: task["priority"] - task["workers_num"] * 10, reverse=True) |
| 120 | |
| 121 | for task in self.tasks: # Find a task |
| 122 | if task["peers"] and peer not in task["peers"]: |
| 123 | continue # This peer not allowed to pick this task |
| 124 | if peer in task["failed"]: |
| 125 | continue # Peer already tried to solve this, but failed |
| 126 | if task["optional_hash_id"] and task["peers"] is None: |
| 127 | continue # No peers found yet for the optional task |
| 128 | return task |
| 129 | |
| 130 | def removeSolvedFileTasks(self, mark_as_good=True): |
| 131 | for task in self.tasks[:]: |
no outgoing calls
no test coverage detected