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

Received unregistered task of type #9015

Open
13 of 19 tasks
tariqjamal-abdulazeez opened this issue May 9, 2024 · 0 comments
Open
13 of 19 tasks

Received unregistered task of type #9015

tariqjamal-abdulazeez opened this issue May 9, 2024 · 0 comments

Comments

@tariqjamal-abdulazeez
Copy link

tariqjamal-abdulazeez commented May 9, 2024

Checklist

  • I have verified that the issue exists against the main branch of Celery.
  • This has already been asked to the discussions forum first.
  • I have read the relevant section in the
    contribution guide
    on reporting bugs.
  • I have checked the issues list
    for similar or identical bug reports.
  • I have checked the pull requests list
    for existing proposed fixes.
  • I have checked the commit log
    to find out if the bug was already fixed in the main branch.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).
  • I have tried to reproduce the issue with pytest-celery and added the reproduction script below.

Mandatory Debugging Information

  • I have included the output of celery -A proj report in the issue.
    (if you are not able to do this, then at least specify the Celery
    version affected).
  • I have verified that the issue exists against the main branch of Celery.
  • I have included the contents of pip freeze in the issue.
  • I have included all the versions of all the external dependencies required
    to reproduce this bug.

Optional Debugging Information

  • I have tried reproducing the issue on more than one Python version
    and/or implementation.
  • I have tried reproducing the issue on more than one message broker and/or
    result backend.
  • I have tried reproducing the issue on more than one version of the message
    broker and/or result backend.
  • I have tried reproducing the issue on more than one operating system.
  • I have tried reproducing the issue on more than one workers pool.
  • I have tried reproducing the issue with autoscaling, retries,
    ETA/Countdown & rate limits disabled.
  • I have tried reproducing the issue after downgrading
    and/or upgrading Celery and its dependencies.

Code:
Decorator.py

_P = ParamSpec("_P")
_R = TypeVar("_R")


def async_task(*args: Any, **kwargs: Any):
    def _decorator(func: Callable[_P, Coroutine[Any, Any, _R]]) -> Task:
        sync_call = sync.AsyncToSync(func)
        @celery.task(*args, **kwargs)
        @wraps(func)
        def _decorated(*args: _P.args, **kwargs: _P.kwargs) -> _R:
            return sync_call(*args, **kwargs)
        return _decorated
    return _decorator

Celery config

celery config
celery.conf.broker_url = settings.CELERY_BROKER_URL
celery.conf.result_backend = settings.CELERY_BROKER_URL
celery.conf.broker_connection_retry_on_startup = True

celery.autodiscover_tasks(
    [
        "appname.tasks.task",
    ]
)

appname/tasks/task.py

@async_task()
async def send_welcome_mail(user_details: dict):
    .....

When i call this celery task in first time task was executed correctly but after that for the same task if i try to call it again getting issue as Unregistered task

Below is the issue

Received unregistered task of type 'appname.tasks.task.send_welcome_mail'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?

Please see
https://docs.celeryq.dev/en/latest/internals/protocol.html
for more information.

Related Issues and Possible Duplicates

Related Issues

  • None

Possible Duplicates

  • None

Environment & Settings

Celery version:

celery report Output: celery = "5.4.0"

software -> celery:5.4.0 (opalescent) kombu:5.3.6 py:3.11.8
            billiard:4.2.0 redis:5.0.3
platform -> system:Darwin arch:64bit
            kernel version:23.4.0 imp:CPython
loader   -> celery.loaders.app.AppLoader
settings -> transport:redis results:redis://localhost:6379/

deprecated_settings: None
broker_url: 'redis://localhost:6379//'
result_backend: 'redis://localhost:6379/'
broker_connection_retry_on_startup: True

Python Packages

pip freeze Output:

Other Dependencies

redis = "^5.0.3" asgiref = "^3.8.1"

Expected Behavior

When i call the celery task again and again it need to be executed correctly

Actual Behavior

In first time when i call the celery task it working fine after that if i call the same task again getting the below issue but i hd done the all configurations correctly

Received unregistered task of type 'appname.tasks.task.send_welcome_mail'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?

Please see
https://docs.celeryq.dev/en/latest/internals/protocol.html
for more information.

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

No branches or pull requests

1 participant