summaryrefslogtreecommitdiff
path: root/Mailman/flock.py
diff options
context:
space:
mode:
authorviega1998-06-13 21:51:33 +0000
committerviega1998-06-13 21:51:33 +0000
commit9aff049fdf01b547a9947dd369aec35b6db5c207 (patch)
tree60950e04a2cb1d439b75222511d3d2c43d7fb21d /Mailman/flock.py
parent40fe67b13a13afa7df6d0a104eb9f6ff718392ba (diff)
downloadmailman-9aff049fdf01b547a9947dd369aec35b6db5c207.tar.gz
mailman-9aff049fdf01b547a9947dd369aec35b6db5c207.tar.zst
mailman-9aff049fdf01b547a9947dd369aec35b6db5c207.zip
Sometimes I miss type checking... fixed a collision between a method
and a variable.
Diffstat (limited to 'Mailman/flock.py')
-rw-r--r--Mailman/flock.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Mailman/flock.py b/Mailman/flock.py
index cf1052d91..b77bb44d7 100644
--- a/Mailman/flock.py
+++ b/Mailman/flock.py
@@ -29,7 +29,7 @@ sure no malicious people have access to link() to the lock file.
import socket, os, time
-DEFAULT_HUNG_TIMEOUT = 30
+DEFAULT_HUNG_TIMEOUT = 15
DEFAULT_SLEEP_INTERVAL = .25
AlreadyCalledLockError = "AlreadyCalledLockError"
@@ -43,7 +43,7 @@ class FileLock:
self.hung_timeout = hung_timeout
self.sleep_interval = sleep_interval
self.tmpfname = "%s.%s.%d" % (lockfile, socket.gethostname(), os.getpid())
- self.locked = 0
+ self.is_locked = 0
if not os.path.exists(self.lockfile):
try:
file = open(self.lockfile, "w+")
@@ -61,7 +61,7 @@ class FileLock:
if timeout > 0:
timeout_time = time.time() + timeout
last_pid = -1
- if self.locked:
+ if self.locked():
raise AlreadyCalledLockError
while 1:
os.link(self.lockfile, self.tmpfname)
@@ -69,7 +69,7 @@ class FileLock:
file = open(self.tmpfname, 'w+')
file.write(`os.getpid(),self.tmpfname`)
file.close()
- self.locked = 1
+ self.is_locked = 1
break
if timeout and timeout_time < time.time():
raise TimeOutError
@@ -87,7 +87,7 @@ class FileLock:
file = open(self.tmpfname, 'w+')
file.write(`os.getpid(),self.tmpfname`)
os.unlink(winner)
- self.locked = 1
+ self.is_locked = 1
break
os.unlink(self.tmpfname)
time.sleep(self.sleep_interval)
@@ -95,6 +95,7 @@ class FileLock:
def unlock(self):
if not self.locked():
raise NotLockedError
+ self.is_locked = 0
os.unlink(self.tmpfname)
def locked(self):
- return os.path.exists(self.tmpfname) and self.locked \ No newline at end of file
+ return os.path.exists(self.tmpfname) and self.is_locked \ No newline at end of file