Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
@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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda