1.1 --- a/imiptools/filesys.py Fri Nov 06 17:17:22 2015 +0100
1.2 +++ b/imiptools/filesys.py Fri Nov 06 18:34:33 2015 +0100
1.3 @@ -172,10 +172,16 @@
1.4 parts = parts and list(parts) or []
1.5 target = parts[:]
1.6
1.7 - # Move the directory.
1.8 + # Move the directory to a unique name. This prevents unlikely but
1.9 + # possible conflicts as a slow unlocking process is caught up by a
1.10 + # following, faster locking-then-unlocking process which would then
1.11 + # try and rename the active lock directory to a common old lock
1.12 + # directory name, causing a "directory not empty" exception and the
1.13 + # continued existence of the lock.
1.14
1.15 parts.append(self.lock_name)
1.16 - target.append(self.old_lock_name)
1.17 + old_lock_name = "%s.%d" % (self.old_lock_name, getpid())
1.18 + target.append(old_lock_name)
1.19 rename(self.get_object_in_store(*parts), self.get_object_in_store(*target))
1.20
1.21 # Then remove the moved directory and its contents.