[DB-SIG] Handling an open database connection after a fork?
mwm-keyword-dbsig.588a7d at mired.org
Sat Jan 12 21:27:45 CET 2008
On Sat, 12 Jan 2008 14:14:03 +0100 "M.-A. Lemburg" <mal at egenix.com> wrote:
> On 2008-01-11 17:35, Mike Meyer wrote:
> > 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?
> That depends on the database module you're using.
As stated, cx_Oracle.
> In general, it's better to avoid all this and only load the module
> for the first time after the fork (both in the parent and child
Not possible. Which is why I need to find out what to do to make
oracle (via cx_Oracle) happy.
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