[DB-SIG] Handling an open database connection after a fork?

Mike Meyer mwm at mired.org
Fri Jan 11 17:35:33 CET 2008


I have an application that's using oracle (via cx_Oracle) to log
events (among other things). It runs in multiple processes, forking
new processes as it needs them.

I.e.

db = cx_Oracle.connect(.....)
cu = db.cursor()

[do various things, including sql inserts and commits]

if fork():
   # Parent wants to keep the existing database connection.
else:
   # Child wants a database connection.

So the question is - what should the child do to get a database
connection? Can it just keep using the existing db & cu variables? If
not, does it need to do anything special, or avoid doing anything, in
order to not disrupt the parent processes use of those variables?

      thanx,
      <mike
-- 
Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.


More information about the DB-SIG mailing list