On Nov 5, 3:40 am, "Brent Pedersen" <[EMAIL PROTECTED]> wrote:
> On 7/14/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Jul 14, 8:15 pm, "Ben Hoyt" <[EMAIL PROTECTED]> wrote:
> > > > This is definitely a problem in psycopg2 and I probably should log an
> > > > issue against that package telling them that their package is unusable
>
> > > Aha! Thank you, thank you very much!
>
> > > We haven't tried daemon mode yet (will soon), but if C modules are only
> > > loaded once per process instead of once per interpreter, then yeah, that's
> > > definitely the problem. What a nightmare!
>
> > > PyObject *decimal = PyImport_ImportModule("decimal");
>
> > > > if (decimal) {
> > > > decimalType = PyObject_GetAttrString(decimal, "Decimal");
> > > > }
>
> > > Incidentally, we looked at that code snippet just the other day, and it
> > > *looked* fine then ... but of course we hadn't realised the thing about C
> > > modules only being loaded once per process.
>
> > > Does this mean there'd be no easy way to fix this problem using mod_python
> > > (unless psycopg2 was fixed)?
>
> > Correct, if using just mod_python there wouldn't be a way around it
> > except for fixing psycopg2. At least in mod_wsgi one can use daemon
> > mode to delegate applications to separate processes thereby avoiding
> > the issue.
>
> > I am actually quite surprised that this issue hasn't come up
> > previously with mod_python as the code in psycopg2 has been there for
> > many years.
>
> > FWIW, I have extended my documentation on application issues when
> > using mod_wsgi to add a section on problems with multiple
> > interpreters.
>
> > http://code.google.com/p/modwsgi/wiki/ApplicationIssues
>
> > Described there are general problems with extension modules when using
> > multiple sub interpreters, plus this specific issue.
>
> > Look forward to seeing how you go with daemon mode of mod_wsgi as a
> > way of getting around this.
>
> > Graham
>
> so i've hit this problem as well though i think it might have been
> with a datetime object, not a decimal.... i've switched to pgdb for
> now, but prefer psycopg2. is it confirmed that psycopg2 works in
> daemon mode? i am ignorant of how that works, would it be restricted
> to processes=1 threads=1 in order to avoid similar problems?
> thanks,
The issue is not number of processes and/or threads, but which sub
interpreter the application runs in and whether there are other
applications in same process running in other sub interpreters.
In short, delegate each application to a separate daemon process using
mod_wsgi daemon mode. Then force the application to run in the main
interpreter of their respective processes, by setting:
WSGIApplicationGroup %{GLOBAL}
So, one application per process group and all running in the main
Python interpreter and not a secondary sub interpreter.
Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---