------------------------------------------------------------
revno: 6789
committer: Barry Warsaw <[email protected]>
branch nick: 3.0
timestamp: Tue 2009-08-25 18:49:43 -0400
message:
Remove the special cases for pylint. Version 0.18 "works" out of the box
now, except that it has a bug where it can't handle "from __future__ import
absolute_import".
Robustify master.py so that we can't get into a situation where the pid
dictionary changes size during iteration. No test, but this should be fixed.
modified:
buildout.cfg
setup.py
src/mailman/bin/arch.py
src/mailman/bin/master.py
--
lp:mailman
https://code.launchpad.net/~mailman-coders/mailman/3.0
Your team Mailman Checkins is subscribed to branch lp:mailman.
To unsubscribe from this branch go to
https://code.launchpad.net/~mailman-coders/mailman/3.0/+edit-subscription.
=== modified file 'buildout.cfg'
--- buildout.cfg 2009-06-30 10:14:49 +0000
+++ buildout.cfg 2009-08-25 22:49:43 +0000
@@ -45,7 +45,6 @@
[pylint]
recipe = zc.recipe.egg
eggs =
- logilab.pylintinstaller
- pylint==0.15.2
+ pylint
entry-points = pylint=pylint.lint:Run
arguments = sys.argv[1:]
=== modified file 'setup.py'
--- setup.py 2009-08-09 14:49:35 +0000
+++ setup.py 2009-08-25 22:49:43 +0000
@@ -42,6 +42,8 @@
import mailman.commands
import mailman.messages
+# Create the .mo files from the .po files. There may be errors and warnings
+# here and that could cause the digester.txt test to fail.
start_dir = os.path.dirname(mailman.messages.__file__)
for dirpath, dirnames, filenames in os.walk(start_dir):
for filename in filenames:
=== modified file 'src/mailman/bin/arch.py'
--- src/mailman/bin/arch.py 2009-01-01 22:16:51 +0000
+++ src/mailman/bin/arch.py 2009-08-25 22:49:43 +0000
@@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import absolute_import, unicode_literals
+
import os
import sys
import errno
=== modified file 'src/mailman/bin/master.py'
--- src/mailman/bin/master.py 2009-08-09 14:49:35 +0000
+++ src/mailman/bin/master.py 2009-08-25 22:49:43 +0000
@@ -220,6 +220,66 @@
+class PIDWatcher:
+ """A class which safely manages child process ids."""
+
+ def __init__(self):
+ self._pids = {}
+
+ def __iter__(self):
+ # Safely iterate over all the keys in the dictionary. Because
+ # asynchronous signals are involved, the dictionary's size could
+ # change during iteration. Iterate over a copy of the keys to avoid
+ # that.
+ for pid in self._pids.keys():
+ yield pid
+
+ def add(self, pid, info):
+ """Add process information.
+
+ :param pid: The process id. The watcher must not already be tracking
+ this process id.
+ :type pid: int
+ :param info: The process information.
+ :type info: 4-tuple consisting of
+ (queue-runner-name, slice-number, slice-count, restart-count)
+ """
+ old_info = self._pids.get(pid)
+ assert old_info is None, (
+ 'Duplicate process id {0} with existing info: {1}'.format(
+ pid, old_info))
+ self._pids[pid] = info
+
+ def pop(self, pid):
+ """Remove and return existing process information.
+
+ :param pid: The process id. The watcher must already be tracking this
+ process id.
+ :type pid: int
+ :return: The process information.
+ :rtype: 4-tuple consisting of
+ (queue-runner-name, slice-number, slice-count, restart-count)
+ :raise KeyError: if the process id is not being tracked.
+ """
+ return self._pids.pop(pid)
+
+ def drop(self, pid):
+ """Remove and return existing process information.
+
+ This is like `pop()` except that no `KeyError` is raised if the
+ process id is not being tracked.
+
+ :param pid: The process id.
+ :type pid: int
+ :return: The process information, or None if the process id is not
+ being tracked.
+ :rtype: 4-tuple consisting of
+ (queue-runner-name, slice-number, slice-count, restart-count)
+ """
+ return self._pids.pop(pid, None)
+
+
+
class Loop:
"""Main control loop class."""
@@ -227,7 +287,7 @@
self._lock = lock
self._restartable = restartable
self._config_file = config_file
- self._kids = {}
+ self._kids = PIDWatcher()
def install_signal_handlers(self):
"""Install various signals handlers for control from mailmanctl."""
@@ -336,7 +396,7 @@
pid = self._start_runner(spec)
log = logging.getLogger('mailman.qrunner')
log.debug('[%d] %s', pid, spec)
- self._kids[pid] = info
+ self._kids.add(pid, info)
def loop(self):
"""Main loop.
@@ -394,8 +454,9 @@
# SIGTERM or we aren't restarting.
if restart:
spec = '%s:%d:%d' % (qrname, slice_number, count)
- newpid = self._start_runner(spec)
- self._kids[newpid] = (qrname, slice_number, count, restarts)
+ new_pid = self._start_runner(spec)
+ new_info = (qrname, slice_number, count, restarts)
+ self._kids.add(new_pid, new_info)
def cleanup(self):
"""Ensure that all children have exited."""
@@ -414,7 +475,7 @@
try:
# pylint: disable-msg=W0612
pid, status = os.wait()
- del self._kids[pid]
+ self._kids.drop(pid)
except OSError, e:
if e.errno == errno.ECHILD:
break
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org