For the inspiration, look here:

https://websauna.org/docs/narrative/misc/task.html

On Thu, 10 Jan 2019 at 14:27, Zsolt Ero <[email protected]> wrote:

> So I guess the simplest possible solution is Celery + Redis (since I'm
> already using Redis for sessions), I guess?
>
> On Thu, 10 Jan 2019 at 13:55, Thierry Florac <[email protected]> wrote:
> >
> > Hi,
> >
> > After-commit hooks don't work in async mode!
> > They allow to declare callbacks which will be called after transaction
> commit, but server is waiting for these callbacks to be finished (in
> synchronous mode) before sending response to client.
> > If you need async mode, you have (at least) to start another thread
> which will handle your asynchronous tasks.
> >
> > Regards,
> > Thierry
> >
> >
> > Le jeu. 10 janv. 2019 à 13:37, Zsolt Ero <[email protected]> a écrit :
> >>
> >> Actually, it doesn't result in async-like behaviour, the client is
> >> still waiting for the function inside the commit hook. I guess I don't
> >> understand the concept then.
> >>
> >> On Thu, 10 Jan 2019 at 13:15, Zsolt Ero <[email protected]> wrote:
> >> >
> >> > 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 a topic in
> the Google Groups "pylons-discuss" group.
> >> > To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pylons-discuss/tf5kKsnZRTc/unsubscribe.
> >> > To unsubscribe from this group and all its topics, 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.
> >>
> >> --
> >> 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/CAKw-smAukCYyjhg7wp2PoP4cUCJ0JuchNqYG0LLHpVGGL%2B84mA%40mail.gmail.com
> .
> >> For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> > --
> > http://www.imagesdusport.com -- http://pyams.readthedocs.io
> >
> > --
> > You received this message because you are subscribed to a topic in the
> Google Groups "pylons-discuss" group.
> > To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pylons-discuss/tf5kKsnZRTc/unsubscribe.
> > To unsubscribe from this group and all its topics, 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/CAPX_VWCt_SfPDmYsVSK%2Bwt74j5%2BSFj8vb40LrN9PRBPY2%2Bb7Gg%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> 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/CAKw-smCPd0j-sCuHzMa0b-sXNdXrRzB%2BWs2JHzsx5Tu6w02c7A%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAK8RCUsOopJMrWhdPP7EC%2Bk4kio38fMT94ziu0KX6a%3DMqvJT6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to