简体   繁体   中英

Running celery worker from inside the project

I have an application which has the follow structure:

proj/
    __init__.py
    script1.py
    script2.py
    celery.py
    ...

The problem is that the project was initially written with the root directory inside the proj. Ie import don't start with import proj.script1 but are import script1 . Now, if I try to start the worker from the directory above proj , it obviously messes things up. I tried adding sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) in celery.py with hopes to add the correct directory to the path but it still doesn't work.

Any suggestions?

So the workaround for me was to put celery.py inside another directory and then run worker while being in proj/ .

Current directory structure:

proj/
    __init__.py
    script1.py
    script2.py
    Celery/
        celery.py
    ...

Not very beautiful but works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM