summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-07-20 11:23:11 +0300
committerPanu Matilainen <pmatilai@redhat.com>2007-07-20 11:23:11 +0300
commit6fdd71bbeef3d1c1b731b9fbbbfad792715c3a1f (patch)
tree65f2551eef8060d5e61d85e286d798d5e43e6b2d /python
parenta9f84cb15e00decc28598dfded8b1c4867bd8a9a (diff)
downloadrpm-6fdd71bbeef3d1c1b731b9fbbbfad792715c3a1f.tar.gz
rpm-6fdd71bbeef3d1c1b731b9fbbbfad792715c3a1f.tar.bz2
rpm-6fdd71bbeef3d1c1b731b9fbbbfad792715c3a1f.zip
Force rpmdb clean termination on exit from python.
Python process tracebacking with active iterators can and will otherwise leave stale locks around (as is presumably the reason for rhbz#235389 and various other locking issues)
Diffstat (limited to 'python')
-rw-r--r--python/rpmmodule.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 85b6db257..9f6742e3c 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -227,6 +227,16 @@ static PyMethodDef rpmModuleMethods[] = {
{ NULL }
} ;
+/*
+* Force clean up of open iterators and dbs on exit.
+* This ends up calling exit() while we're already exiting but exit
+* handlers will only get called once so it wont loop.
+*/
+static void rpm_exithook(void)
+{
+ rpmdbCheckTerminate(1);
+}
+
/**
*/
static char rpm__doc__[] =
@@ -265,6 +275,13 @@ void init_rpm(void)
if (m == NULL)
return;
+ /*
+ * treat error to register rpm cleanup hook as fatal, tracebacks
+ * can and will leave stale locks around if we can't clean up
+ */
+ if (Py_AtExit(rpm_exithook) == -1)
+ return;
+
rpmReadConfigFiles(NULL, NULL);
d = PyModule_GetDict(m);