Skip to content

Commit db63723

Browse files
committed
update
1 parent 6857bd2 commit db63723

2 files changed

Lines changed: 30 additions & 38 deletions

File tree

Mailman/Queue/Switchboard.py

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -213,46 +213,23 @@ def dequeue(self, filebase):
213213
mailman_log('warning', 'Queue file does not exist: %s (not found in backup or shunt either)', filename)
214214
return None, None
215215

216-
# Create a lock file
217-
lockfile = filename + '.lock'
218-
try:
219-
# Try to create the lock file
220-
fd = os.open(lockfile, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o644)
221-
os.close(fd)
222-
except OSError as e:
223-
if e.errno != errno.EEXIST:
224-
mailman_log('error', 'Switchboard.dequeue: Failed to create lock file for %s: %s', filebase, str(e))
225-
raise
226-
mailman_log('debug', 'Queue file %s is currently locked by another process', filename)
227-
return None, None
228-
216+
# Read the message object and metadata.
217+
fp = open(filename, 'rb')
218+
# Move the file to the backup file name for processing. If this
219+
# process crashes uncleanly the .bak file will be used to re-instate
220+
# the .pck file in order to try again.
221+
os.rename(filename, bakfile)
229222
try:
230-
# Read the message and metadata
231-
try:
232-
msg, data = self._dequeue(filename)
233-
# Add filebase to msgdata for cleanup
234-
if data is not None:
235-
data['filebase'] = filebase
236-
# Log the full msgdata after dequeuing
237-
mailman_log('debug', 'Switchboard.dequeue: Successfully dequeued file %s', filebase)
238-
except Exception as e:
239-
mailman_log('error', 'Switchboard.dequeue: Failed to read message from %s: %s\nTraceback:\n%s',
240-
filebase, str(e), traceback.format_exc())
241-
raise
242-
243-
# Validate data structure before returning
244-
if not isinstance(data, dict):
245-
mailman_log('error', 'Switchboard.dequeue: Invalid data structure in %s: expected dict, got %s',
246-
filename, type(data))
247-
return None, None
248-
249-
return msg, data
223+
msg = pickle.load(fp, fix_imports=True, encoding='latin1')
224+
data = pickle.load(fp, fix_imports=True, encoding='latin1')
250225
finally:
251-
# Always clean up the lock file
252-
try:
253-
os.unlink(lockfile)
254-
except OSError:
255-
pass
226+
fp.close()
227+
if data.get('_parsemsg'):
228+
msg = email.message_from_string(msg, Message)
229+
# Add filebase to msgdata for cleanup
230+
if data is not None:
231+
data['filebase'] = filebase
232+
return msg, data
256233

257234
def finish(self, filebase, preserve=False):
258235
"""Finish processing a file by either removing it or moving it to the shunt queue.

Makefile.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ PYTHON_FILES = $(shell find . -name "*.py")
7474
PYTHON_DIRS = $(shell find . -type d -name "Mailman")
7575
INSTALLED_SCRIPTS = $(shell find $(DESTDIR)$(prefix)/bin -type f -executable 2>/dev/null || true)
7676
SOURCE_SCRIPTS = $(shell find build/bin -type f -executable -name "*.py" 2>/dev/null || true)
77+
PYLINT = pylint
78+
PYLINT_FLAGS = --disable=C0111,C0103,C0303,W0311,W0603,W0621,R0903,R0913,R0914,R0915
7779

7880
# Detect number of CPUs for parallel builds
7981
ifeq ($(shell uname -s),Darwin)
@@ -130,6 +132,19 @@ define check_lang_file
130132
exit 1;
131133
endef
132134

135+
# Add lint target
136+
.PHONY: lint
137+
lint:
138+
@echo "Running pylint on installed Python files..."
139+
@if [ -d "$(DESTDIR)$(prefix)" ]; then \
140+
find $(DESTDIR)$(prefix) -name "*.py" -type f -print0 | \
141+
xargs -0 $(PYLINT) $(PYLINT_FLAGS) || true; \
142+
else \
143+
echo "No installed files found at $(DESTDIR)$(prefix)"; \
144+
echo "Please run 'make install' first"; \
145+
exit 1; \
146+
fi
147+
133148
# Rules
134149

135150
.PHONY: all build install clean distclean prepare-build clean-pyc doinstall update langpack

0 commit comments

Comments
 (0)