Skip to content
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

possibility to set on_message callback for single task #3477

Merged
merged 5 commits into from
Sep 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions celery/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
from celery import states
from celery import current_app, group, maybe_signature
from celery.app import current_task
from celery.exceptions import ChordError, TimeoutError, TaskRevokedError
from celery.exceptions import (
ChordError, TimeoutError, TaskRevokedError, ImproperlyConfigured,
)
from celery.five import items
from celery.result import (
GroupResult, ResultBase, allow_join_result, result_from_tuple,
Expand Down Expand Up @@ -428,9 +430,13 @@ def iter_native(self, result, timeout=None, interval=0.5, no_ack=True,
)

def wait_for_pending(self, result, timeout=None, interval=0.5,
no_ack=True, on_interval=None, callback=None,
propagate=True):
no_ack=True, on_message=None, on_interval=None,
callback=None, propagate=True):
self._ensure_not_eager()
if on_message is not None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if this condition can cause following issue? Mq backed is not supported for on_message ? @xbeastx @auvipy
http://stackoverflow.com/questions/40784593/celery-raise-improperlyconfigured-exception

raise ImproperlyConfigured(
'Backend does not support on_message callback')

meta = self.wait_for(
result.id, timeout=timeout,
interval=interval,
Expand Down
5 changes: 3 additions & 2 deletions celery/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def revoke(self, connection=None, terminate=False, signal=None,
reply=wait, timeout=timeout)

def get(self, timeout=None, propagate=True, interval=0.5,
no_ack=True, follow_parents=True, callback=None, on_interval=None,
EXCEPTION_STATES=states.EXCEPTION_STATES,
no_ack=True, follow_parents=True, callback=None, on_message=None,
on_interval=None, EXCEPTION_STATES=states.EXCEPTION_STATES,
PROPAGATE_STATES=states.PROPAGATE_STATES):
"""Wait until task is ready, and return its result.

Expand Down Expand Up @@ -185,6 +185,7 @@ def get(self, timeout=None, propagate=True, interval=0.5,
no_ack=no_ack,
propagate=propagate,
callback=callback,
on_message=on_message,
)
wait = get # deprecated alias to :meth:`get`.

Expand Down