What I tried but is not working:
if __name__ == "__main__":
# Start celery worker in detached mode
app.worker_main(argv = ['-A', 'myapp', 'worker', '-Q', 'myqueue', '-D'])
# Other python code operations that need celery worker to run properly ...
# Shutdown celery worker
app.worker_main(argv = ['-A', 'myapp', 'control', 'shutdown'])
When I run this script, it executes and ends without any error, but the celery worker did not get launched and the python code after is not executed.
How to solve this ?