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

Getting Started has Circular Import Issue #8561

Closed
4 tasks done
david-waterworth opened this issue Oct 10, 2023 · 1 comment · Fixed by #8600
Closed
4 tasks done

Getting Started has Circular Import Issue #8561

david-waterworth opened this issue Oct 10, 2023 · 1 comment · Fixed by #8600

Comments

@david-waterworth
Copy link

david-waterworth commented Oct 10, 2023

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

@frolenkov-nikita
Copy link
Contributor

This problem is mentioned in the documentation.

The :program:`celery` program can be used to start the worker (you need to run the worker in the directory above proj):

However, I think that the documentation can be improved for this case if we add a folder above in the project structure, like src/proj

Please consider my pull request.

@auvipy auvipy added this to the 5.3.x milestone Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants