Skip to content

Commit

Permalink
Merge pull request #74 from alexandrevicenzi/test-xmlrpc-worker
Browse files Browse the repository at this point in the history
tests: test xml-rpc worker functions
  • Loading branch information
rohanpm authored Nov 2, 2018
2 parents bd90acb + 5e5fe2a commit 6cd31a1
Show file tree
Hide file tree
Showing 3 changed files with 1,271 additions and 3 deletions.
8 changes: 6 additions & 2 deletions kobo/hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,11 @@ def timeout_task(self, recursive=True):
try:
self.__lock(self.worker_id, new_state=TASK_STATES["TIMEOUT"], initial_states=(TASK_STATES["OPEN"], ))
except (MultipleObjectsReturned, ObjectDoesNotExist):
raise Exception("Cannot interrupt task %d, state is %s" % (self.id, self.get_state_display()))
raise Exception("Cannot timeout task %d, state is %s" % (self.id, self.get_state_display()))

if recursive:
for task in self.subtasks():
task.interrupt_task(recursive=True)
task.timeout_task(recursive=True)
self.logs.gzip_logs()

@transaction.atomic
Expand Down Expand Up @@ -993,6 +993,10 @@ def check_wait(self, child_task_list=None):

return [finished, unfinished]

def set_weight(self, weight):
self.weight = weight
self.save()


def _task_delete(sender, instance, **kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion kobo/hub/xmlrpc/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def fail_task(request, task_id, task_result):
@validate_worker
def set_task_weight(request, task_id, weight):
task = Task.objects.get_and_verify(task_id=task_id, worker=request.worker)
task.setWeight(weight)
task.set_weight(weight)
return task.weight


Expand Down
Loading

0 comments on commit 6cd31a1

Please sign in to comment.