That's right, tgext.asyncjob starts the thread in daemon mode, so there is no guarantee that your thread will finish in a clear way. Whenever the master process terminates, the thread does too.
That was the choice made as the worker is bound to the application process and I didn't want to have the application block waiting for the worker to complete during a restart as the use case for asyncjob was mostly related to transient/idempotent tasks like exporting a file to user. I'll gladly review and merge any patch to add graceful shutdown of the worker. Just make sure it's optional for anyone willing to keep the current quick shutdown behaviour. On Fri, Jun 3, 2016 at 12:41 PM, Damien Accorsi <[email protected]> wrote: > Hi Alessandro, > > By investigationg with Bastien about threading in turbogears, we found > that tgext.asyncjob worker thread is not stopped gracefully. (the code > includes a raw "while True". > Would you be interested in us to implement a gracefull stop of the thread ? > > Currently in case of long-term asynchronous operations (especially writing > in database), this may result in dirty/unexpected data/behavior. > > If so, where is the original repo of tgext.asyncjob ? > https://bitbucket.org/axant/tgext.asyncjob ? > > > Damien > > > > Le 30/05/2016 à 22:39, Alessandro Molina a écrit : > > Usually the best way to achieve this is: > > - Through the environment_loaded milestone if you need it to happen once > per process ( > http://turbogears.readthedocs.io/en/latest/turbogears/configuration/appconfig.html#configuration-milestones > ) > - Through the configure_new_app hook if you need it to happen once for > each TG application created by a process ( > <http://turbogears.readthedocs.io/en/latest/turbogears/hooks.html#available-hooks> > http://turbogears.readthedocs.io/en/latest/turbogears/hooks.html#available-hooks > ) > > On Mon, May 30, 2016 at 10:00 AM, Bastien Sevajol < > [email protected]> wrote: > >> Hi, >> >> I need to execute code once my application is itilialized and ready to >> use (auth methods usage, etc). >> Place my code in tg.configuration.app_config.AppConfig#after_init_config >> is right place ? >> >> To expose my situation: I want to launch in subprocess, a radicale server >> instance who use my app auth methods. >> >> Thank's, >> Bastien. >> -- >> You received this message because you are subscribed to the Google Groups >> "TurboGears" 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]> >> [email protected]. >> Visit this group at https://groups.google.com/group/turbogears. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" 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]. > Visit this group at https://groups.google.com/group/turbogears. > For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" 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]. > Visit this group at https://groups.google.com/group/turbogears. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "TurboGears" 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]. Visit this group at https://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

