Here is an WIP of the implementation: review45461002
It is already working. I publish it to get feedback's on the API and some choices.
Principal choices are:
- Usage of advisory lock to pull tasks
- Usage of listen/notify when available
- Launch task at the end of requests if no worker is configured (but reuse as much as possible worker code)
- Use multiprocess as pool of worker
- Model.__queue__ API which is restricted to have record(s) as first argument (instance method or class method)
- Use scheduled and expected timestamp as priority of the queue
- Allow to run worker for a specific queue name
The next step will be to update modules to use it when possible.