gisce/oorq — pull request #4 by ecarreras (2013-04-27 09:38:10+00:00)
Title: Splitter

Make a decorator for a `spliter_job`.

This will permit to standard OpenObject functions as `def foo(self, cursor, uid, ids, context=None):` to split the `ids` into chunks, then every chunk of ids will be converted to a job. Then for each id call the execute method. This means that every execute(id) is executed independently in one database transaction.

The failed chunks well be moved to the 'failed' queue.

### Pseudocode

**Chunks maker**

```python
def make_chunks(ids, size):
return [ids[x:x + size] for x in xrange(0, len(ids), size)]
```

**OpenObject executor**

```python
res = []
failed_ids = []
for exe_id in chunk:
args[0] = [exe_id]
try:
res.append(osv_.execute(dbname, uid, obj, method, *args, **kw))
except:
failed_ids.append(exe_id)
if failed_ids:
# Make a new job with attributes of the current job but with the chunk ids
# and move it to failed queue
pass
return res
```

This will enable OpenERP distributed multiprocessor.