On 10/18/06, Niels <[EMAIL PROTECTED]> wrote:

Rafael SDM Sierra wrote:
> Hi, Trying to make Django to use really only ONE connection to ONE process
> (like 1000 Threads using 1 connection) I've altered postgresql backend at
> base.py. The beta (aka bugged) version is here:
>
> http://pastebin.com/808647
>
> My question is if this alteration (turn the connection variable to be a
> Class-attribute instead of Instance-attribute) would generate some problem
> in the future.
>

I recall from postgress documentation that you can't share database
connection handles across threads... Does
http://www.postgresql.org/docs/8.1/static/libpq-threading.html apply?

I don't know how much it is applied to my application, because Django uses cursor and (teorically) one connection could have more than one cursor

But then again, as your class variable is in a class subclassed from
theading.local it appears to me that each thread would see its own
private connection. Anyone to confirm or comment on this?

In my application with 1000+ threads I got only one connection with 1000+ cursors, and it seems to be working (maybe??)

I ran into problems myself on win32/mod_python/postgress where the
limit of 100 connection was hit... but mine is a more complicated case
as i connect to django in a PythonTranslateHandler for certain urls. I
had to manually call connection.close() when/after the database is
accessed. As forking on windows is quite expensive and postgres uses a
child process for each connection, avoiding the fork overhead would
make a big difference.

I don't will run my app in windows, so it can not be a problem to me..:P


--
SDM Underlinux
Garimpar.com
--
PEP-8
Só existem 3 tipos de pessoas no mundo, as que sabem contar, e as que não sabem.
CPFL - Compania Piratininga de FALTA de Luz (6 vezes em 5 dias!!)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django developers" 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/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to