Skip to content

Getting Started has Circular Import Issue #8561

@david-waterworth

Description

@david-waterworth

Checklist

  • 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).

Related Issues and Possible Duplicates

Related Issues

  • None

Possible Duplicates

  • None

Description

getting-started/next-steps.html has an example as follows

Project Structure

proj/__init__.py
    /celery.py
    /tasks.py

celery.py

from celery import Celery

app = Celery('proj',
             broker='amqp://',
             backend='rpc://',
             include=['proj.tasks'])

# Optional configuration, see the application user guide.
app.conf.update(
    result_expires=3600,
)

if __name__ == '__main__':
    app.start()

I cannot get this to work - how can you import Celery from the celery module in a file also called celery - won't that create a circular import?

Also the error from running celery -A proj worker -l INFO in the project root is

Error: Invalid value for '-A' / '--app': 
Unable to load celery application.
Module 'proj.celery' has no attribute 'celery'

This implies that its expecting the Celery instance to be called celery not app I think. In either case the examples don't seem to work without modification.

I've been using celery in projects fine, but I had to follow third party tutorials - which used a different pattern (i.e. using celeryapp.py as the filename, and explicitly specifying the celery instance in the worker run command). I couldn't get started using the official guides though.

Suggestions

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions