You should be able to go with:

import transaction
for attempt in transaction.attempts(3):
   [...]

It should also be possible to extend it to all your controllers by
using a controller_wrapper.
Simple add to your config/app_cfg.py something like:

def transactions_retry_wrapper(app_config, controller):
    def wrapped_controller(*args, **kw):
        for attempt in transaction.attempts(3):
            return controller(*args, **kw)
    return wrapped_controller

base_config.register_hook('controller_wrapper', transactions_retry_wrapper)

Just keep in mind that controller wrappers are a recent addition, I'm
sure they are available on 2.2 and 2.1.5, but I don't remember if they
are on 2.1.4

On Thu, Nov 1, 2012 at 1:01 AM, kgk <[email protected]> wrote:
>
> Hello,
>
>   We have a TG 2.1.5 application running against Postgresql and Amazon RDS.
> We are often getting a OperationError or a ConcurrentModificationError
> during some long transactions.   The usual way to deal with them is laid out
> in [1], which suggests
> that the user should simply resubmit transaction due to the transient error.
> After looking around repoze.tm2 I note that
> it doesn't look like it will retry.
>
> 1.  Any suggestions for implementing  retries at transaction.manager level..
> should we be using the zope.sqlalchemy manager
> which does seem to implement some of the retry logic?
>
> It also seems that we could simply ask the client side to reload (return a
> http 409) and resubmit the entire request. Anybody
> have any   experience with this ?
>
> Thanks,
> Kris
>
>
>
>
>
> [1] http://www.zodb.org/zodbbook/transactions.html
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/5T23ID0fzmgJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to