[tor-commits] [thandy/master] Fix possible race condition with os.path.exists

nickm at torproject.org nickm at torproject.org
Thu Nov 3 19:14:20 UTC 2011


commit 53e9b2b3c0b10b3b0075da6acc59c032553813b7
Author: Tomás Touceda <chiiph at torproject.org>
Date:   Thu Oct 20 10:54:16 2011 -0300

    Fix possible race condition with os.path.exists
---
 lib/thandy/packagesys/ThpPackages.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/thandy/packagesys/ThpPackages.py b/lib/thandy/packagesys/ThpPackages.py
index e4e12f6..da76c6b 100644
--- a/lib/thandy/packagesys/ThpPackages.py
+++ b/lib/thandy/packagesys/ThpPackages.py
@@ -27,8 +27,10 @@ class ThpDB(object):
         if self._thp_db_root is None:
           raise Exception("There is no THP_DB_ROOT variable set")
         dbpath = os.path.join(self._thp_db_root, "pkg-status")
-        if not os.path.exists(dbpath):
+        try:
             os.mkdir(dbpath)
+        except OSError, e:
+            pass
 
     def getPath(self):
         """ Returns the path to the database root """





More information about the tor-commits mailing list