-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…10107) * Celery: cheat `job_status` view to return `finished` after 5 polls The frontend hits this endpoint every 1s. As we don't know when the task has finished now since we disabled the Celery result backend, we are just cheating it and return finished after 5 times the view is called with the same `task_id`. This fixes the issue we have in the UI when clicking the circled arrows to re-sync the remote repositories. * Update readthedocs/api/v2/views/task_views.py Co-authored-by: Anthony <aj@ohess.org> --------- Co-authored-by: Anthony <aj@ohess.org>
- Loading branch information
Showing
6 changed files
with
23 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Utilities for retrieving task data.""" | ||
|
||
from celery import states | ||
from celery.result import AsyncResult | ||
|
||
|
||
__all__ = ('TaskNotFound', 'get_task_data') | ||
__all__ = ("TaskNotFound",) | ||
|
||
|
||
class TaskNotFound(Exception): | ||
|
||
def __init__(self, task_id, *args, **kwargs): | ||
message = 'No public task found with id {id}'.format(id=task_id) | ||
super().__init__(message, *args, **kwargs) | ||
|
||
|
||
def get_task_data(task_id): | ||
""" | ||
Will raise `TaskNotFound` if the task is in state ``PENDING`` or the task. | ||
meta data has no ``'task_name'`` key set. | ||
""" | ||
from readthedocs.worker import app | ||
|
||
result = AsyncResult(task_id) | ||
state, info = result.state, result.info | ||
if state == states.PENDING: | ||
raise TaskNotFound(task_id) | ||
if 'task_name' not in info: | ||
raise TaskNotFound(task_id) | ||
try: | ||
task = app.tasks[info['task_name']] | ||
except KeyError: | ||
raise TaskNotFound(task_id) | ||
return task, state, info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters