Wednesday 30 June 2021

how to time an entire process from beginning to completion and set up a termination execution time?

I have the following celery chain process:

@app.task(name='bcakground')
def background_task():    
    
    now = datetime.now() 
       
    ids = [700,701,708,722,783,799]
    for id in ids:
        my_process = chain(taks1.s(id), task2.s())
        my_process()
    
    end = datetime.now()
    return ['ENDED IN',(end-now).total_seconds()] 

Q1: How can I tell how long it takes for this task to complete from beginning to end? The result I get to (ENDED IN) doesnt reflect the truth because the chain is run in parallel and the results are a fraction of second.

Q2 is there any way to place a termination timeout in the event the entire process of background_task takes longer then 25 minutes?



from how to time an entire process from beginning to completion and set up a termination execution time?

No comments:

Post a Comment