Is there an option to pass variable to celery worker on start and use it inside worker on execution time?
I'm writing server that will be responsible for machine learning training and evaluation. I would like to dynamically start new instance of worker and pass variable to it that will be used to load specific model inside.
I found how to start worker from answers here with worker_main
method.
I was thinking about two solutions:
Set it as environmental variable. The problem with this solution is that it can be corrupted when two instances of worker will be created the same time.
Pass it as an argv but I don't know how to read the variable inside worker.
EDIT
I found this thread but it only talks about accessing custom parameter in task. My question is about accessing it at worker initialization.
Inspired by this thread I'll try with celery signals. http://docs.celeryproject.org/en/latest/userguide/signals.html#worker-init