Strange behavior for interrupt_tasks and timeout_tasks

Open
#71 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start by locating the interrupt_tasks and timeout_tasks implementations and compare their return and exception behavior. Determine the intended outcome for failed or partially processed tasks, then add coverage showing the chosen behavior is consistent and complete.

Written by the indexing model from the issue text.

Description

The code for interrupt_tasks and timeout_tasks are very similar.

def timeout_tasks(request, task_list):
    result = True
    for task_id in task_list:
        task = Task.objects.get_and_verify(task_id=task_id, worker=request.worker)
        if task:
            try:
                task.timeout_task(recursive=True)
            except:
                raise
                result = False
    return result

The strange part is the result variable, this function only returns True, if for some reason task.timeout_task raises an error result = False is never reached because it re-raises the error.

Some options available for fixing this:

  • Do not return anything and re-raise
  • Do not re-raise and return False
  • Do not re-raise and return the actual count of tasks changed. If the input was 10 tasks but only 5 were interrupted return the number 5.
Dominant language
Python
Stars
16
Forks
38
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from release-engineering/kobo

All issues in release-engineering/kobo

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.