I'm just now implementing this. Are you saying that basically, by using 
addAfterCommitHook, I can replace put relatively fast (say, <10 seconds), 
functions into async-like behaviour, without requiring any external queue 
service?

old:

# send email was an async function, via a decorator (using Huey)
send_email(
    to_email=user.email,
    subject='account activation',
    text=email_text,
)





new: 

request.tm.get().addAfterCommitHook(send_email_hook, kws=dict(
    to_email=user.email,
    subject='account activation',
    text=email_text,
))


+ a helper function:


def send_email_hook(success, **kwargs):
    if success:
        send_email(**kwargs)

I have two questions regarding this:
1. When does success == False?
2. What does the warning on transaction's doc page mean?

Hook functions which do raise or propagate exceptions will leave the 
> application in an undefined state. 


Practically speaking, should I put the send_email function into a 
try-except block?

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/6831e434-6e85-4c41-9797-82c71ad7f2b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to