A Dilluns, 16 de maig de 2011 13:26:06, Cédric Krier va escriure:
> The idea will be to have something like:
> 
>     queries = {}
>     for record in self.browse(ids):
>         queries[record.id] = Async(self.search, [...], order=[('x',
> 'ASC')], limit=1)
> 
>     for id, query in queries.iteritems():
>         ids = query.result()
>         if ids:
>             ...
> 
> The Async method will be in charge of setting a new cursor for the thread,
> creating a thread and keep the result until the main thread will read it.
> Of course, for backend that doesn't support multi-threading, the method
> will do the query directly.

Having easy to use Async calls would be great. I think that in this case the 
API could be optimized so the second loop "consumes" results as soon as 
they're available so if the first one takes a long time to compute doesn't lock 
the rest. 

What I don't know is how transactions work. If you create a new cursor will it 
create a new transaction too? If it worked like that it could cause many 
problemes because maybe some of the "ids" in the main loop may not be 
available in the new transaction, either because they were not commited or 
because they were removed in another transaction.

-- 
Albert Cervera i Areny
http://www.NaN-tic.com
OpenERP Partners
Tel: +34 93 553 18 03
skype: nan-oficina

http://twitter.com/albertnan 
http://www.nan-tic.com/blog

-- 
[email protected] mailing list

Reply via email to