← Back to team overview

openerp-india team mailing list archive

[Bug 944273] Re: Scheduler is not working when OpenERP is running with gunicorn

 

The problem appears to be that the current code does not work in a
multiprocessor and multi-threaded environment. There are a couple of
solutions:

1. Simple Solution
Just have the thread running and checking every 60 seconds, with no wake-ups. This is demonstrated in this branch: lp:~jamesj/openobject-server/simple-cron-fix.

2. More Complex Solution
To keep the wake-up functionality (more-or-less the same), it is possible to use the python multiprocessing module (http://docs.python.org/library/multiprocessing.html). This allows the process to have both local and remote concurrency, and to have data to be passed between the processes. This involves replacing the Python 'threading' module with the 'Process' module, and replacing 'heapq' with 'Queue' (the multiprocessing version). A merge proposal from branch lp:~jamesj/openobject-server/complex-cron-fix has been provided.

-- 
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