← Back to team overview

openerp-connector-community team mailing list archive

Re: Is synchronous communication possible ?

 

No, this is not how it works actually. If you use delay() it will be pushed in the queue, and the job will be executed in its own transaction, not the current one. If you decide to not use the delay() on the function, so there is no queuing, the function is executed like any other function at the moment it is called in a totally synchronous manner.

I think it would be possible, as a new feature, to extend the job decorator so it would add another attribute like my_function.delay_sync() that would push the job in a memory queue local to the current cr, that'd be executed just before the commit. The difficulty here would come from the Cursor class in OpenERP that is not designed to be extended and would require to be monkey-patched... :-( I already did some tests around that).


On 02/19/2014 03:31 PM, Lionel Sausin wrote:
Thanks.
Then, may I also assume that I could push jobs to a queue and decide
where/when to run all at once, and raise an error if something fails?
If I can do this at the right moment (say, at the ORM's commit time),
that would spare me the cost of multiple network connections, while
keeping the code pretty readable.
Lionel.

Le 19/02/2014 11:29, Guewen Baconnier a écrit :
Totally possible.

The connector is composed of many pieces, as a developer you do what
you want and can use a piece or another but not all of them if you want.

A job is a simple function decorated with @job [0]
Calling .delay() on a decorated function will push it as a job in the
queue. But calling the function directly will execute it
synchronously, because it's still a normal function. It means that
changing a @job function to be executed synchronously or
asynchronously is a 8 chars change.

[0]
http://openerp-connector.com/api/api_queue.html#connector.queue.job.job





--
Guewen Baconnier
Business Solutions Software Developer

Camptocamp SA
PSE A, CH-1015 Lausanne
Phone: +41 21 619 10 39
Office: +41 21 619 10 10
http://www.camptocamp.com/


Follow ups

References