There is a project, in it, in one of the applications there are signals and tasks, in the tasks.py and signals.py

When in apps.py I do this:

 from django.apps import AppConfig class MyAppConfig(AppConfig): name = 'proj.myapp' verbose_name = "MyApp" def ready(self): import proj.myapp.signals 

then running celery -A proj.taskapp worker -B -E -l info displays:

 [tasks] . gglobal.taskapp.celery.debug_task 

that is, my tasks from proj/myapp/tasks.py not registered.

However, if I am def ready(self): I write pass , that is, I don’t import signals as in the example above, then all my tasks from proj/myapp/tasks.py are logged normally.

What could be the problem ?

ADDITION

at the same time, so:

 def ready(self): import proj.myapp.tasks import proj.myapp.signals 

it works, and here it is:

 def ready(self): import proj.myapp.signals import proj.myapp.tasks 

not

  • Cyclic import no chance? - andreymal
  • No, I do not swear at anything. Just at the start of Celery, my tasks are not visible. - Narnik Gamarnik
  • Nobody will swear at cyclical imports, trace the import chain by code independently (although in this case it’s not a fact that this is the case, but cyclic imports should always be avoided) - andreymal
  • In general, I just imported the signals.py task from tasks.py, but when I deleted the import and the task itself from the signals, the result did not change. He spent several hours searching for the reasons for such behavior, but this led to nothing. - Narnik Gamarnik

0