From 77ad0bb15714fbc4e6065a8c61fb337b90d80991 Mon Sep 17 00:00:00 2001 From: bwarsaw <> Date: Mon, 1 Dec 2003 00:56:11 +0000 Subject: repend(): An interface for putting request data back into the request database. --- Mailman/Pending.py | 23 +++++++++++++++++++---- 1 file 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) @@ -165,6 +163,22 @@ def confirm(cookie, expunge=True): lock.unlock() + +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(): -- cgit v1.2.3