Skip to content

deadlock warning / exception inappropriate #3498

Closed

Description

@jptrainor

I see the following warning appearing in my Celery 3.1.23 log:

[2016-10-07 07:42:29,096: WARNING/Worker-1] /usr/local/lib/python2.7/dist-packages/celery/result.py:45: RuntimeWarning: Never call result.get() within a task!
See http://docs.celeryq.org/en/latest/userguide/tasks.html#task-synchronous-subtasks

In Celery 3.2 this will result in an exception being
raised instead of just being a warning.

  warnings.warn(RuntimeWarning(E_WOULDBLOCK))

In my use case there is no possibility of dead lock because the get() is waiting on a result from a task that is executing via a separate queue and on a different worker's thread pool. I worked around the warning by simply implementing a busy wait on the async result ready() status. That work around is acceptable in my use-case. It would not, of course, be acceptable in all use-cases.

My take on this is that deadlock comes with the territory and is a design issue that is the responsibility of the developer. It does not seem appropriate for the underlying tool to raise a warning, or exception, in this case. Particularly when the warning, or exception, is i) incorrect in some cases, and ii) trivial to work around thereby defeating its purpose.

Activity

  1. ask commented on Oct 10, 2016

    @ask
    Contributor

    You can disable the warning using:

    from celery.result import allow_join_result
    
    with allow_join_result():
        result.get()
  2. jptrainor commented on Oct 11, 2016

    @jptrainor
    Author

    Thanks, that worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions