Expiring Database Connections

T

Tim Roberts

This question is only marginally related to Python, but I'm going to ask it
here because (a) this is the most tolerant group in the comp.lang
hierarchy, and (b) people in this group would know the answer.

Many of the Python-based web solutions use a long-running process: WebWare,
FastCGI, and mod_python all run an interpreter long-term, and keep the
classes loaded until the web server stops.

On Windows, with some databases, this represents a problem. With Access
specifically, and with SQLite occasionally, having an open database
connection can make it impossible to open the database from another
process, such as from a command line. It seems to me that I could solve
this problem by starting up a deadman timer when a database connection is
opened, and if no additional connections are made in, say, one or two
minutes, close the database connection completely.

I'm wondering if anyone has done such a thing and/or has any thoughts or
comments. My web searches were unsuccessful.
 
D

drs

Tim Roberts said:
Many of the Python-based web solutions use a long-running process: WebWare,
FastCGI, and mod_python all run an interpreter long-term, and keep the
classes loaded until the web server stops.

On Windows, with some databases, this represents a problem. With Access
specifically, and with SQLite occasionally, having an open database
connection can make it impossible to open the database from another
process, such as from a command line. It seems to me that I could solve
this problem by starting up a deadman timer when a database connection is
opened, and if no additional connections are made in, say, one or two
minutes, close the database connection completely.

I'm wondering if anyone has done such a thing and/or has any thoughts or
comments. My web searches were unsuccessful.

Perhaps you could create a middle tier between the web and db to hold and or
pool the db connections. This way, you don't need to worry about which web
processes continue to run, you can share the connection object among them so
you don't have to close it at all, and you'll have a bit more control.

-drs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top