0

I'm getting started with celery and I want to know if it is possible to add modules to celeryd processes that have already been started. In other words, instead of adding modules via celeryconfig.py as in

CELERY_IMPORTS = ("tasks", "additional_module" )

before starting the workers, I want to make additional_module available later somehow after the worker processes have started.

thanks in advance.

1 Answer 1

2

You can achieve your goal by starting a new celeryd with an expanded import list and eventually gracefully shutting down your old worker (after it's finished its current jobs).

Because of the asynchronous nature of getting jobs pushed to you and only marking them done after celery has finished its work, you won't actually miss any work doing it this way. You should be able to run the celery workers on the same machine - they'll simply show up as new connections to RabbitMQ (or whatever queue backend you use).

Sign up to request clarification or add additional context in comments.

3 Comments

how would I start a new celery worker from within the client? I think you can shutdown workers from inside the client, but how do you start one?
I didn't clearly state what I meant - I should have said start a new celery daemon (i.e. celeryd). I've updated my post.
Is this advice still relevant / best practise, as I write this, Aug 2014, or have better ways come along? I have many custom functions that I am trying for numerical optimization which takes ages (therefore using Celery to run them on numerous computers), so I would like to send new functions to all the workers, periodically, increasing the range of different optimization functions available to each worker, on the fly. I've read about module reload on the fly but this seems a bit clunky? Can I just send new functions over periodically, in say, a dict, guaranteeing all workers will get them?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.