diff options
author | bwarsaw <> | 2003-12-01 00:56:11 +0000 |
---|---|---|
committer | bwarsaw <> | 2003-12-01 00:56:11 +0000 |
commit | 77ad0bb15714fbc4e6065a8c61fb337b90d80991 (patch) | |
tree | c7b3e5fdb7ada4b51cfb38858c6248ed1297267d /Mailman | |
parent | a4e5d1bfdfb293c008b57ff20a9bfa29b39de43c (diff) | |
download | mailman2-77ad0bb15714fbc4e6065a8c61fb337b90d80991.tar.gz mailman2-77ad0bb15714fbc4e6065a8c61fb337b90d80991.tar.xz mailman2-77ad0bb15714fbc4e6065a8c61fb337b90d80991.zip |
repend(): An interface for putting request data back into the request
database.
Diffstat (limited to 'Mailman')
-rw-r--r-- | Mailman/Pending.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Mailman/Pending.py b/Mailman/Pending.py index 82a067cf..598863f9 100644 --- a/Mailman/Pending.py +++ b/Mailman/Pending.py @@ -62,10 +62,9 @@ def new(*content): # It's a programming error if this assertion fails! We do it this way so # the assert test won't fail if the sequence is empty. assert content[:1] in _ALLKEYS - # Get a lock handle now, but only lock inside the loop. - lock = LockFile.LockFile(LOCKFILE, - withlogging=mm_cfg.PENDINGDB_LOCK_DEBUGGING) + lock = LockFile.LockFile( + LOCKFILE, withlogging=mm_cfg.PENDINGDB_LOCK_DEBUGGING) # We try the main loop several times. If we get a lock error somewhere # (for instance because someone broke the lock) we simply try again. retries = mm_cfg.PENDINGDB_LOCK_ATTEMPTS @@ -128,7 +127,6 @@ def confirm(cookie, expunge=True): if content is missing: return None return content - # Get a lock handle now, but only lock inside the loop. lock = LockFile.LockFile(LOCKFILE, withlogging=mm_cfg.PENDINGDB_LOCK_DEBUGGING) @@ -166,6 +164,22 @@ def confirm(cookie, expunge=True): +def repend(cookie, data): + # Get a lock + lock = LockFile.LockFile( + LOCKFILE, withlogging=mm_cfg.PENDINGDB_LOCK_DEBUGGING) + lock.lock() + try: + # Load the database + db = _load() + db[cookie] = data + db['evictions'][cookie] = time.time() + mm_cfg.PENDING_REQUEST_LIFE + _save(db, lock) + finally: + lock.unlock() + + + def _load(): # The list's lock must be acquired if you wish to alter data and save. # @@ -190,6 +204,7 @@ def _load(): fp.close() + def _save(db, lock): # Lock must be acquired before loading the data that is now being saved. if not lock.locked(): |