A
A
Andrey Gorshenin2018-06-15 09:27:07
Python
Andrey Gorshenin, 2018-06-15 09:27:07

Why does a background process start multiple background processes?

Good afternoon!
I have code like this in Python 3.x that runs the first function first, it runs the second before it completes, and then the first again. It was assumed that these two functions, performing some work once in a time interval, would work on the server constantly, in a circle:

@shared_task
def Task1(arg1):

    Task2.apply_async((arg2,), countdown=86400)


@shared_task
def Task2(arg2):

    rnd = random.randint(3600, 21600)
    cd = 86400 + rnd

    Task1.apply_async((arg1,), countdown=cd)

(I omitted the function code for readability, it does not seem to affect the essence of the question)
The problem is that function 2, launched by function 1, starts several functions 1 at the end of its work, which was not intended.
I use python 3, celery[redis] version 3.1.20-1 in my work on Ubuntu.
I would be grateful for your help in resolving this issue.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question