You can try tgext.asyncjob it might do most of the work for you.
It will manage the session for you letting you just use the
model.DBSession inside the asynchronous threads.
About the session, by default TurboGears already provides a
sessionmaker which will create one scoped_session for each thread that
will try to use the DBSession object. The main issue is that TG
patches the session to use a different transactions manager which runs
inside the TG middleware stack by committing and reverting session
whenever is necessary. When you use the session outside of a request
anyway this middleware is not in place and so you will have to manage
the session yourself. By default tgext.asyncjob implements a worker
that behaves like TG, committing the session at the end of the async
function and reverting it in case of an exception.
Also pay attention that when you query an object from a different
thread it might not be available even thought you are sure that it
should be, to avoid this issue tgext.asyncjob provides a
asyncjob_timed_query that tries to retrieve an object from the
database multiple times until it excedes timeout.
I have similar scripts to his for user/group setup I will send you
samples tomorrow with the argparse stuff for selecting the ini file.
It is no rocket science you might find the solution before tomorrow.
Le 6 oct. 2011 à 18:56, Sean DiZazzo <half.i...@gmail.com> a
écrit :
> --
> You received this message because you are subscribed to the Google
> Groups "TurboGears" group.
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to turbogears+...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
> .
>
There is no little pleasure
A thanks though is bigger pleasure. :) thanks
Hf gl
Le 7 oct. 2011 à 01:02, Sean DiZazzo <half.i...@gmail.com> a
écrit :
> On Oct 6, 12:18 pm, Julien Tayon <jta...@gmail.com> wrote: