convert celery worker file to binary using pyinstaller

Viewed 308

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 Answers
  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 !!!!!

Related