Skip to Content
Menu
This question has been flagged
3 Replies
33376 Views

I have a very long process of invoice generation and validation that works when I do it from the browser (even if it takes several hours to complete). I created a cron task that executes the same process. I can see that the cron successfully starts, but it seems to never finish. It must be silently killed, because I can see no error.

Do you know if there is some timeout for the cron tasks ? If so, how can I change this setting in order to increase the timeout limit ?

Avatar
Discard
Best Answer

no time-out is set at CRON job.

but the openerp-server has a time-out.  

1. If time-out needs to be increased, you need to configure openerp-server parameters.

These are the basic options available at OpenERP.

  Multiprocessing options:
    --workers=WORKERS   Specify the number of workers, 0 disable prefork mode.
    --limit-memory-soft=LIMIT_MEMORY_SOFT
                        Maximum allowed virtual memory per worker, when
                        reached the worker be reset after the current request
                        (default 671088640 aka 640MB).
    --limit-memory-hard=LIMIT_MEMORY_HARD
                        Maximum allowed virtual memory per worker, when
                        reached, any memory allocation will fail (default
                        805306368 aka 768MB).
    --limit-time-cpu=LIMIT_TIME_CPU
                        Maximum allowed CPU time per request (default 60).
    --limit-time-real=LIMIT_TIME_REAL
                        Maximum allowed Real time per request (default 120).
    --limit-request=LIMIT_REQUEST
                        Maximum number of request to be processed per worker
                        (default 8192).

2. After every update of record, if it is successful. force the cursor to commit

try:
     YOUR CODE
except Exception as e:
      Handle exception if needed
cr.commit()

By doing this, you could avoid processing the same records if the CRON job is killed due to TIME-OUT.

Avatar
Discard
Author

Thank you very much for this complete answer. If I have no timeout when I do the request from the browser, does it mean that my issue is not a server timeout ? Why would it be different when executing by a cron ? Nice tip for the commit, I will try to use it.

Best Answer

You can also use threading concept to override this issue

snapshot


import threading



def process_record(self):
with api.Environment.manage():
new_cr = self.pool.cursor()
self = self.with_env(self.env(cr=new_cr))

​//your logic code

new_cr.commit()
new_cr.close()

def threading_method(self):
threaded_calculation = threading.Thread(target=self.process_record, args=())
threaded_calculation.start()
return True

In above method I have pass method name in threading to override cron task timeout issue
Avatar
Discard

Can you share some more details?

Swagat Parida

Can you please come to my cabin for more information??

Best Answer

Very googd. 


I solved my problem with the following values:

--limit-time-cpu=150
--limit-time-real=250

Thanks.

Avatar
Discard