Reset tempfile module after fork where useful
authorMichael Hanselmann <hansmi@google.com>
Wed, 17 Feb 2010 15:53:41 +0000 (16:53 +0100)
committerMichael Hanselmann <hansmi@google.com>
Thu, 18 Feb 2010 12:21:15 +0000 (13:21 +0100)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/http/server.py
lib/utils.py

index c49cb4b..1e564c1 100644 (file)
@@ -32,6 +32,7 @@ import signal
 import asyncore
 
 from ganeti import http
+from ganeti import utils
 
 
 WEEKDAYNAME = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
@@ -532,6 +533,9 @@ class HttpServer(http.HttpBase, asyncore.dispatcher):
           pass
         self.socket = None
 
+        # In case the handler code uses temporary files
+        utils.ResetTempfileModule()
+
         self.request_executor(self, connection, client_addr)
       except Exception: # pylint: disable-msg=W0703
         logging.exception("Error while handling request from %s:%s",
index d3735a8..c8a22c9 100644 (file)
@@ -2057,6 +2057,9 @@ def RunInSeparateProcess(fn):
   if pid == 0:
     # Child process
     try:
+      # In case the function uses temporary files
+      ResetTempfileModule()
+
       # Call function
       result = int(bool(fn()))
       assert result in (0, 1)