diff options
| author | Barry Warsaw | 2008-12-31 18:26:08 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2008-12-31 18:26:08 -0500 |
| commit | 996f7ea88ad5eaee7b7c7df5b113dbf6ce896e55 (patch) | |
| tree | fccf6fa070e9ea90d6834491f4406d803473e8da /mailman/bin | |
| parent | 03d01d66436661ef7d1e6a80401a6ed232d02718 (diff) | |
| download | mailman-996f7ea88ad5eaee7b7c7df5b113dbf6ce896e55.tar.gz mailman-996f7ea88ad5eaee7b7c7df5b113dbf6ce896e55.tar.zst mailman-996f7ea88ad5eaee7b7c7df5b113dbf6ce896e55.zip | |
More test repairs.
* Move the lmtp configurations to lazr.config
* Fixes to master.py
* In qrunner.py, don't override initialize()
* Make sure subprocesses get configured correctly during tests
Diffstat (limited to 'mailman/bin')
| -rw-r--r-- | mailman/bin/master.py | 15 | ||||
| -rw-r--r-- | mailman/bin/qrunner.py | 30 |
2 files changed, 22 insertions, 23 deletions
diff --git a/mailman/bin/master.py b/mailman/bin/master.py index 129df0009..e47e0d839 100644 --- a/mailman/bin/master.py +++ b/mailman/bin/master.py @@ -318,11 +318,10 @@ class Loop: qrunner_config = getattr(config, section_name) if not qrunner_config.start: continue - class_path = qrunner_config['class'].split(DOT) - package = DOT.join(class_path[:-1]) + package, class_name = qrunner_config['class'].rsplit(DOT, 1) __import__(package) # Let AttributeError propagate. - class_ = getattr(sys.modules[package], class_path[-1]) + class_ = getattr(sys.modules[package], class_name) # Find out how many qrunners to instantiate. This must be a power # of 2. count = int(qrunner_config.instances) @@ -331,7 +330,7 @@ class Loop: for slice_number in range(count): # qrunner name, slice #, # of slices, restart count info = (name, slice_number, count, 0) - spec = '%s:%d:%d' % (qrname, slice_number, count) + spec = '%s:%d:%d' % (name, slice_number, count) pid = self._start_runner(spec) log = logging.getLogger('mailman.qrunner') log.debug('[%d] %s', pid, spec) @@ -369,12 +368,14 @@ class Loop: # command line switch was not given. This lets us better handle # runaway restarts (e.g. if the subprocess had a syntax error!) qrname, slice_number, count, restarts = self._kids.pop(pid) + config_name = 'qrunner.' + qrname restart = False if why == signal.SIGUSR1 and self._restartable: restart = True # Have we hit the maximum number of restarts? restarts += 1 - if restarts > config.MAX_RESTARTS: + max_restarts = int(getattr(config, config_name).max_restarts) + if restarts > max_restarts: restart = False # Are we permanently non-restartable? log.debug("""\ @@ -383,10 +384,10 @@ Master detected subprocess exit pid, why, qrname, slice_number + 1, count, ('[restarting]' if restart else '')) # See if we've reached the maximum number of allowable restarts - if restarts > config.MAX_RESTARTS: + if restarts > max_restarts: log.info("""\ qrunner %s reached maximum restart limit of %d, not restarting.""", - qrname, config.MAX_RESTARTS) + qrname, max_restarts) # Now perhaps restart the process unless it exited with a # SIGTERM or we aren't restarting. if restart: diff --git a/mailman/bin/qrunner.py b/mailman/bin/qrunner.py index 422809fa3..dea8f4053 100644 --- a/mailman/bin/qrunner.py +++ b/mailman/bin/qrunner.py @@ -19,8 +19,8 @@ import sys import signal import logging -from mailman import loginit -from mailman.configuration import config +from mailman.config import config +from mailman.core.logging import reopen from mailman.i18n import _ from mailman.options import Options @@ -112,10 +112,6 @@ This should only be used when running qrunner as a subprocess of the mailmanctl startup script. It changes some of the exit-on-error behavior to work better with that framework.""")) - def initialize(self): - """Override initialization to propagate logs correctly.""" - super(ScriptOptions, self).initialize(not self.options.subproc) - def sanity_check(self): if self.arguments: self.parser.error(_('Unexpected arguments')) @@ -126,28 +122,30 @@ work better with that framework.""")) def make_qrunner(name, slice, range, once=False): # Several conventions for specifying the runner name are supported. It - # could be one of the shortcut names. Or the name is a full module path, + # could be one of the shortcut names. If the name is a full module path, # use it explicitly. If the name starts with a dot, it's a class name # relative to the Mailman.queue package. - if name in config.qrunner_shortcuts: - classpath = config.qrunner_shortcuts[name] + qrunner_config = getattr(config, 'qrunner.' + name, None) + if qrunner_config is not None: + # It was a shortcut name. + class_path = qrunner_config['class'] elif name.startswith('.'): - classpath = 'mailman.queue' + name + class_path = 'mailman.queue' + name else: - classpath = name - modulename, classname = classpath.rsplit('.', 1) + class_path = name + module_name, class_name = class_path.rsplit('.', 1) try: - __import__(modulename) + __import__(module_name) except ImportError, e: if config.options.options.subproc: # Exit with SIGTERM exit code so the master watcher won't try to # restart us. - print >> sys.stderr, _('Cannot import runner module: $modulename') + print >> sys.stderr, _('Cannot import runner module: $module_name') print >> sys.stderr, e sys.exit(signal.SIGTERM) else: raise - qrclass = getattr(sys.modules[modulename], classname) + qrclass = getattr(sys.modules[module_name], class_name) if once: # Subclass to hack in the setting of the stop flag in _do_periodic() class Once(qrclass): @@ -191,7 +189,7 @@ def set_signals(loop): signal.signal(signal.SIGUSR1, sigusr1_handler) # SIGHUP just tells us to rotate our log files. def sighup_handler(signum, frame): - loginit.reopen() + reopen() log.info('%s qrunner caught SIGHUP. Reopening logs.', loop.name()) signal.signal(signal.SIGHUP, sighup_handler) |
