I have worked with antoine :)
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 <[email protected]> a
écrit :
On Oct 5, 4:08 pm, Alessandro Molina <[email protected]>
wrote:
On Wed, Oct 5, 2011 at 5:36 AM, Sean DiZazzo
<[email protected]> wrote:
Hi,I have a Turbogears 2.1.2 app that kicks off a long running
parallel task. The task is run in many threads and on several
machines,and they all need to use the model to update the database.
What are the best practices for running DBSessions in threads? I
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.
I have seen that code before and it's very nice. It won't quite work
on my project, but I will try to steal the relevant transaction
parts. Parts of my code are not run in the typical Turbogears
controller and run as daemons on other boxes. I have tried to create
the same environment on those client boxes, but when I switched the
code to use the DBSession from tg, I started getting errors like:
UnboundExecutionError: Could not locate a bind configured on mapper
Mapper|Job|jobs, SQL expression or this Session
I think some part of the environment is not set correctly. What is
the minimum I need to do to be able to use the DBSession without these
errors? I see lots of posts regarding this issue. Would following
this solve the issue? http://permalink.gmane.org/gmane.comp.web.turbogears/43261
or is there an alternative suggested way? Thanks!
~Sean
--
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
.
--
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.