You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by st...@apache.org on 2012/05/11 17:48:19 UTC

svn commit: r1337312 - /incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py

Author: stroucki
Date: Fri May 11 17:48:18 2012
New Revision: 1337312

URL: http://svn.apache.org/viewvc?rev=1337312&view=rev
Log:
pickled: suppress exception until save function can be properly serialized.

Modified:
    incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py

Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py?rev=1337312&r1=1337311&r2=1337312&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py Fri May 11 17:48:18 2012
@@ -54,6 +54,7 @@ class Pickled(FromConfig):
 		return ch
 	
 	def save(self):
+		# XXXstroucki lock here to serialize saves
 		filename = self.file
 		# XXXstroucki could be better
 		tempfile = "%s.new" % filename
@@ -61,7 +62,13 @@ class Pickled(FromConfig):
 		file = open(tempfile, "w")
 		cPickle.dump((self.cleanHosts(), self.cleanInstances(), self.networks, self.users), file)
 		file.close()
-		os.rename(tempfile, filename)
+		try:
+			os.rename(tempfile, filename)
+		except OSError:
+			# XXXstroucki: regular save will take place
+			# soon enough, ignore this until locking is
+			# in place.
+			pass
 
 	def load(self):
 		if (os.access(self.file, os.F_OK)):