Answer the question
In order to leave comments, you need to log in
How to kill task in celery djnago?
There is a task, if there is an exception or a certain condition is not met, you need to kill the task, how to do it?
Example:
@task
def test_task():
try:
t = 60*3
while t > 0:
r = requests.get \
('url')
if r.status_code == 200:
strs = json.loads(r.text)
bal = float(strs['totalReceived'])
total = float(strs['totalSent'])
if bal == total:
return "Все ок"
else:
time.sleep(1*60)
t -= 1*60
continue
else:
time.sleep(1*60)
t -= 1*60
continue
if t == 0:
return "Ошибка"
except:
return "Ошибочка"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question