Skip to content
Snippets Groups Projects
Commit 5871d040 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Fixed a bug in celery state handling

parent 111b4401
No related branches found
No related tags found
No related merge requests found
...@@ -15,14 +15,16 @@ logger = logging.getLogger(__name__) ...@@ -15,14 +15,16 @@ logger = logging.getLogger(__name__)
# https://stackoverflow.com/questions/9824172/find-out-whether-celery-task-exists # https://stackoverflow.com/questions/9824172/find-out-whether-celery-task-exists
@after_task_publish.connect @after_task_publish.connect
def update_submitted_state(sender=None, **kwargs): def update_submitted_state(sender, headers, **kwargs):
"""Add 'SUBMITTED' state to celery task.""" """Add 'SUBMITTED' state to celery task."""
# the task may not exist if sent using `send_task` which # the task may not exist if sent using `send_task` which
# sends tasks by name, so fall back to the default result backend # sends tasks by name, so fall back to the default result backend
# if that is the case. # if that is the case.
task = current_app.tasks.get(sender) task = current_app.tasks.get(sender)
backend = task.backend if task else current_app.backend backend = task.backend if task else current_app.backend
backend.store_result(kwargs['headers']['id'], None, "SUBMITTED") backend.store_result(task_id=headers['id'],
result=None,
state='SUBMITTED')
def make_celery(app: Flask) -> Celery: def make_celery(app: Flask) -> Celery:
......
...@@ -31,7 +31,6 @@ setup( ...@@ -31,7 +31,6 @@ setup(
'PyYAML', 'PyYAML',
'pycryptodomex', 'pycryptodomex',
'rpy2', 'rpy2',
'tzlocal',
'flake8', 'flake8',
'pytest', 'pytest',
'pytest-runner', 'pytest-runner',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment