Question

I need help to clarify some concepts. Right now I'm using celery(a python scheduler) to run a task. Since celery has time limit for a task(300s should be default) and my task is very likely to run longer, I decided to spawn a process inside that task to do the actual work. However, what I don't know is that if during the execution of the task, I accidentally restart/stop celery server, will the process that spawned still working? Or it will become a zombie process? Please give me some details if possible. Thanks!

Edit: One more question: when you do

p = Process(target=f, args=('test',))
p.start()

Does p become a child process for current process? Or it just create an independent process?

Était-ce utile?

La solution

I'm afraid I can only answer your first question, not being very familiar with Celery, perhaps you can find the answer in the docs.

Your question highlights the distinction between daemon and non-daemon threads.

Daemon threads are those which will not hang up the main program. They will keep working until they finish, regardless of what the main program is doing.

Non-Daemon threads are just the opposite. They must be killed before the main program ends.

This question/answer does a good job of explaining the difference and implications.

In the scope of your question, if your processes are daemon threads, they should be fine if you restart/stop your server. However, if they aren't daemon threads, you shouldn't be able to stop the celery server (assuming my understanding of daemon threads is correct)

Hopefully this helps

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top