471,108 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 software developers and data experts.

Multi Threading Problem with Python + Django + PostgreSQL.

Hello every body. I am new to this forum and also in Python.
Read many things about multi threading in python. But still having problem.

I am using Django Framework with Python having PostgreSQL as backend database with Linux OS. My applications are long running. I am using threading.
The problem I am facing is that the connections that are being created for database(postgres) update are not getting closed even though my threads had returned and updated database successfully. It is not like that the connections are not being reused. They r being reused but after sometime new one is created. Like this it creates too many connections and hence exceeding MAX_CONNECTION limit of postgres conf.

** I am using psycopg2 as adaptor for python to postgres connection. which itself handles the connections(open/close)

Now the problem is with Django / Python / psycopg2 or any thing else??

Mar 26 '08 #1
3 2035
144 100+
Do you close the connection when the thread terminates?
Doesn't the connection timeout from the postgres side?
Mar 27 '08 #2
Actualy the django itself manages connections through that pcycopg (correct me if i am wrong). I am not explicitly opening any database connection. The statements are like below in django . Suppose 'my_table' is name of table.

obj_table = my_table.objects.get(Name = 'David Beckham');

print obj_table.Name
>> David Beckham

So we never explicitly create any connection. So no question about closing it explicitly.
Mar 31 '08 #3
144 100+
if you don't have anything to say about wether or not a connection has to be closed, maybe try to close it from the postgres side with a timeout value or something. if possible
Mar 31 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

37 posts views Thread by ajikoe | last post: by
1 post views Thread by Carl Waldbieser | last post: by
48 posts views Thread by northband | last post: by
113 posts views Thread by John Nagle | last post: by
14 posts views Thread by Akihiro KAYAMA | last post: by
1 post views Thread by Bruce Frederiksen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.