From 40d2bb564d35809d7735d2ec06ba988db7327020 Mon Sep 17 00:00:00 2001
From: Christian Goetze <cg@lindenlab.com>
Date: Thu, 10 Jul 2008 16:52:33 +0000
Subject: [PATCH] QAR-622 merge -r91846:91877
 svn+ssh://svn/svn/linden/branches/scut-newstyle-5

---
 indra/lib/python/indra/base/config.py      |  7 ++++++-
 indra/lib/python/indra/ipc/mysql_pool.py   | 12 ++++++++++++
 indra/lib/python/indra/util/named_query.py |  2 +-
 indra/test/CMakeLists.txt                  |  1 +
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/indra/lib/python/indra/base/config.py b/indra/lib/python/indra/base/config.py
index 9d8da7dd159..1649933d372 100644
--- a/indra/lib/python/indra/base/config.py
+++ b/indra/lib/python/indra/base/config.py
@@ -175,7 +175,12 @@ def load(indra_xml_file = None):
         indra_xml_file = realpath(
             dirname(realpath(__file__)) + "../../../../../../etc/indra.xml")
 
-    _g_config = IndraConfig(indra_xml_file)
+    try:
+        _g_config = IndraConfig(indra_xml_file)
+    except IOError:
+        # indra.xml was not openable, so let's initialize with an empty dict
+        # some code relies on config behaving this way
+        _g_config = IndraConfig(None)
 
 def dump(indra_xml_file, indra_cfg = None, update_in_mem=False):
     '''
diff --git a/indra/lib/python/indra/ipc/mysql_pool.py b/indra/lib/python/indra/ipc/mysql_pool.py
index 2a5a916e745..a2324cf956e 100644
--- a/indra/lib/python/indra/ipc/mysql_pool.py
+++ b/indra/lib/python/indra/ipc/mysql_pool.py
@@ -76,3 +76,15 @@ def get(self):
         converted_kwargs.update(self._kwargs)
         conn.connection_parameters = converted_kwargs
         return conn
+
+    def clear(self):
+        """ Close all connections that this pool still holds a reference to, leaving it empty."""
+        for conn in self.free_items:
+            try:
+                conn.close()
+            except:
+                pass   # even if stuff happens here, we still want to at least try to close all the other connections
+        self.free_items.clear()
+            
+    def __del__(self):
+        self.clear()
diff --git a/indra/lib/python/indra/util/named_query.py b/indra/lib/python/indra/util/named_query.py
index 063ef7932e1..483a9606c8e 100644
--- a/indra/lib/python/indra/util/named_query.py
+++ b/indra/lib/python/indra/util/named_query.py
@@ -47,7 +47,7 @@
 from indra.base import llsd
 from indra.base import config
 
-NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '')
+NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq')
 NQ_FILE_SUFFIX_LEN  = len(NQ_FILE_SUFFIX)
 
 _g_named_manager = None
diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt
index 63e5538388b..03c4731de5f 100644
--- a/indra/test/CMakeLists.txt
+++ b/indra/test/CMakeLists.txt
@@ -140,6 +140,7 @@ if (EXISTS /etc/debian_version_FAIL)
     COMMAND ${PYTHON_EXECUTABLE}
     ARGS
       ${CMAKE_CURRENT_SOURCE_DIR}/test.py
+      --mode=static
       --output=${CMAKE_CURRENT_BINARY_DIR}/py_test_results.txt
       --touch=${CMAKE_CURRENT_BINARY_DIR}/py_tests_ok.txt
     DEPENDS test.py
-- 
GitLab