Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

263
Views
@shared_task decorator doesn't work

The problem: @shared_task decorator doesn't work, when I import data from custom files. I mean, when I start celery, all tasks under @shared_task doesn't appear in list of tasks.

For example, in this case @shared_task decorator doesn't work:

from __future__ import absolute_import, unicode_literals

from celery import shared_task

from .models import foo


@shared_task
def my_foo_backup(id):
    my_foo = foo(....)
    ...
    ...

This is example, when @shared_task works:

from __future__ import absolute_import, unicode_literals

from celery import shared_task


@shared_task
def my_foo_backup(id):
    my_foo = foo(....)
    ...
    ...

Why?!?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The solution to that problem was to move import commands inside the function. In that way it works fine and according to the rules of PEP8.

from __future__ import absolute_import, unicode_literals

from celery import shared_task


@shared_task
def my_foo_backup(id):
    from .models import foo

    my_foo = foo(....)
    ...
    ...
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!