简体   繁体   中英

convert celery worker file to binary using pyinstaller

Is there a way we can convert a celery tasks file using pyinstaller and run it.

i am using pyinstaller --onefile taskfile.py

But how do i run this with celery worker command

  1. The below example is a sample code celery which starts on program execution
from celery import Celery

app = Celery('myapp', broker='amqp://guest@localhost//', fixups=[])


@app.task
def add(x, y):
    return x + y


if __name__ == '__main__':
    app.start(argv=['-A', 'test_celery', 'worker'])
  1. Need to install celery and pyinstaller python package
pip install pyinstaller 
pip install celery
  1. Generate pyinstaller spec file
pyi-makespec file_name_for_celery_task.py
  1. Generate binary file
pyinstaller file_name.spec 

I hope this helps cheers !!!!!

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