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
- 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'])
- Need to install celery and pyinstaller python package
pip install pyinstaller
pip install celery
- Generate pyinstaller spec file
pyi-makespec file_name_for_celery_task.py
- 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.