Skip to content

Commit b7f32d0

Browse files
committed
Fix list locking in CommandRunner to prevent NotLockedError
1 parent 11febe8 commit b7f32d0

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

Mailman/Queue/CommandRunner.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -357,28 +357,29 @@ def _dispose(self, mlist, msg, msgdata):
357357
syslog('vette', 'Precedence: %s message discarded by: %s',
358358
precedence, mlist_obj.GetRequestEmail())
359359
return False
360-
# Do replybot for commands
361-
mlist_obj.Load()
362-
Replybot = get_replybot()
363-
Replybot.process(mlist_obj, msg, msgdata)
364-
if mlist_obj.autorespond_requests == 1:
365-
syslog('vette', 'replied and discard')
366-
# w/discard
367-
return False
368-
# Now craft the response
369-
res = Results(mlist_obj, msg, msgdata)
370-
# BAW: Not all the functions of this qrunner require the list to be
371-
# locked. Still, it's more convenient to lock it here and now and
372-
# deal with lock failures in one place.
360+
361+
# Lock the list before any operations
373362
try:
374363
mlist_obj.Lock(timeout=mm_cfg.LIST_LOCK_TIMEOUT)
375364
except LockFile.TimeOutError:
376365
# Oh well, try again later
377366
return True
378-
# This message will have been delivered to one of mylist-request,
379-
# mylist-join, or mylist-leave, and the message metadata will contain
380-
# a key to which one was used.
367+
381368
try:
369+
# Do replybot for commands
370+
mlist_obj.Load()
371+
Replybot = get_replybot()
372+
Replybot.process(mlist_obj, msg, msgdata)
373+
if mlist_obj.autorespond_requests == 1:
374+
syslog('vette', 'replied and discard')
375+
# w/discard
376+
return False
377+
378+
# Now craft the response
379+
res = Results(mlist_obj, msg, msgdata)
380+
# This message will have been delivered to one of mylist-request,
381+
# mylist-join, or mylist-leave, and the message metadata will contain
382+
# a key to which one was used.
382383
ret = BADCMD
383384
if msgdata.get('torequest', False):
384385
ret = res.process()

0 commit comments

Comments
 (0)