Skip to content

Upgrade celery to >= 4.2 #4643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stsewd opened this issue Sep 18, 2018 · 4 comments · Fixed by #6448
Closed

Upgrade celery to >= 4.2 #4643

stsewd opened this issue Sep 18, 2018 · 4 comments · Fixed by #6448
Labels
Improvement Minor improvement to code Status: blocked Issue is blocked on another issue

Comments

@stsewd
Copy link
Member

stsewd commented Sep 18, 2018

We may need to do some changes before upgrading celery to 4.2, as we face some issues (#4640).

Some options are:

@stsewd stsewd added Improvement Minor improvement to code Status: blocked Issue is blocked on another issue labels Sep 18, 2018
@humitos
Copy link
Member

humitos commented Jan 20, 2019

I just tried with celery==4.2.1 and I got this error:

[20/Jan/2019 12:41:29] readthedocs.doc_builder.environments:553[28603]: ERROR (Build) [test-builds:latest] Never call result.get() within a task!
See http://docs.celeryq.org/en/latest/userguide/tasks.html#task-synchronous-subtasks
Traceback (most recent call last):
  File "/home/humitos/rtfd/code/readthedocs.org/readthedocs/projects/tasks.py", line 562, in run_build
    epub=bool(outcomes['epub']),
  File "/home/humitos/rtfd/code/readthedocs.org/readthedocs/projects/tasks.py", line 731, in update_app_instances
    commit=self.build['commit'],
  File "/home/humitos/rtfd/code/readthedocs.org/readthedocs/core/utils/__init__.py", line 52, in broadcast
    task_promise = chord(tasks, callback).apply_async()
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/celery/canvas.py", line 1230, in apply_async
    body=body, task_id=task_id, **options)
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/celery/canvas.py", line 1239, in apply
    args=(tasks.apply(args, kwargs).get(propagate=propagate),),
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/celery/result.py", line 671, in get
    on_interval=on_interval,
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/celery/result.py", line 722, in join
    assert_will_not_block()
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/celery/result.py", line 41, in assert_will_not_block
    raise RuntimeError(E_WOULDBLOCK)
RuntimeError: Never call result.get() within a task!
See http://docs.celeryq.org/en/latest/userguide/tasks.html#task-synchronous-subtasks

[20/Jan/2019 12:41:29] readthedocs.doc_builder.environments:653[28603]: ERROR Build failed with unhandled exception: Never call result.get() within a task!
See http://docs.celeryq.org/en/latest/userguide/tasks.html#task-synchronous-subtasks

@stsewd
Copy link
Member Author

stsewd commented Mar 13, 2019

This happens when we execute the task with a callback

https://github.com/rtfd/readthedocs.org/blob/54397a07a1baed5b183c0535093643467c3edaba/readthedocs/core/utils/__init__.py#L50

The task is already running in a celery task, so when we call chord, it's basically doing something like

r = task.delay(...)get()
callback(r).delay()

That get is causing the error :)

I'll try to see how we can fix/refactor this

@stsewd
Copy link
Member Author

stsewd commented Mar 13, 2019

So, we can't execute the callback from outside a task anyway, it will block the request :/. So, I guess we just need to ignore the error as the docs shown.

@stsewd
Copy link
Member Author

stsewd commented Mar 14, 2019

I tried a lot of ways, but looks like there is a bug in celery :/

    # Celery's Group class does some special handling when an iterable with
    # len() == 1 is passed in. This will be hit if there is only one server
    # defined in the above queue lists
    if len(tasks) > 1:
        task_promise = group(*tasks).apply_async()
    else:
        task_promise = group(tasks).apply_async()
    if callback:
        task_promise.get(disable_sync_subtasks=False)
        return callback.apply_async()
    return task_promise

celery/celery#5330

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code Status: blocked Issue is blocked on another issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants