openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #08703
[Bug 944273] Re: Scheduler is not working when OpenERP is running with gunicorn
When using Gunicorn, mutliple processes are used, but not multiple
threads.
Without Gunicorn, multiple threads are used (provided Werkzeug is
available). In that case, the cron jobs management is thread-safe (the
use of the heapq is prtoected by locks).
As you have found, openerp.cron.start_master_thread() must be called to
run the master thread. It could be run in the master (gunicorn) process
if needed. But this is not enough: you have to instruct the master cron
thread to check four jobs on a given database. To do so,
schedule_cron_jobs() must be called on a particular registry (also
called pool).
So a possible workaround when using OpenERP for a known database is to
modify the Gunicorn on_starting hook. This can be done for instance by
adding the two above calls in the on_starting() function provided in
openerp/wsgi/core.py.
Another workaround is to run a non-gunicorn OpenERP server process with
the database/registry loaded in order to run the cron jobs but not
necessarily serve client requests (those being served by the gunicorn-
enabled instance).
For multiple databases, probably the best idea is to use the second
above possiblity (a second, cron-only, openerp instance) with some code
(unexisintg for now) to load the necessary databases.
HTH,
Thu
--
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/944273
Title:
Scheduler is not working when OpenERP is running with gunicorn
Status in OpenERP Server:
Confirmed
Bug description:
The OpenERP scheduler ois not working correctly in version 6.1 when
OpenERP is running using gunicorn. In the initial investigations that
I've done I think that the problem is because each gunicorn worker is
running in a separate thread, so the memory space is different.
OpenERP is designed to be stateless, so this should be fine. However,
in the case of the scheduler, tasks are being pushed and popped from
the heap... which will be different for each process.
I think that a more robust solution would be add the tasks to the
database and the cron Master Thread process would read from the
database (instead of the heap).
This is straightforward to verify: create some scheduled actions that
are due to be run (there are some in the system by default) and start
OpenERP using gunicorn. You should see that the scheduled actions
aren't run. Then compare what happens when OpenERP is started in a
single-threaded manner e.g. ./openerp-server -d dbname. This time
you'll see that the schedule actions are run.
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/944273/+subscriptions
References