devtools/__init__.py
changeset 9340 b1e933b0e850
parent 9252 01bca75ee8bd
parent 9337 70f6b183085a
child 9402 2c48c091b6a2
child 9600 bde625698f44
--- a/devtools/__init__.py	Mon Sep 09 12:43:25 2013 +0200
+++ b/devtools/__init__.py	Mon Dec 09 16:13:10 2013 +0100
@@ -26,6 +26,7 @@
 import pickle
 import glob
 import warnings
+import tempfile
 from hashlib import sha1 # pylint: disable=E0611
 from datetime import timedelta
 from os.path import (abspath, join, exists, split, isabs, isdir)
@@ -328,8 +329,9 @@
         # XXX we dump a dict of the config
         # This is an experimental to help config dependant setup (like BFSS) to
         # be propertly restored
-        with open(config_path, 'wb') as conf_file:
+        with tempfile.NamedTemporaryFile(dir=os.path.dirname(config_path), delete=False) as conf_file:
             conf_file.write(pickle.dumps(dict(self.config)))
+        os.rename(conf_file.name, config_path)
         self.db_cache[self.db_cache_key(db_id)] = (backup_data, config_path)
 
     def _backup_database(self, db_id):