diff options
| author | Barry Warsaw | 2009-10-15 22:18:38 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2009-10-15 22:18:38 -0400 |
| commit | d0eff3c214b4940cb30ec1152fcabf0f34f49194 (patch) | |
| tree | 77f68adab3736cb722f53858dde3199240168751 | |
| parent | 37332636e899c023fb31384413578346086c7692 (diff) | |
| download | mailman-d0eff3c214b4940cb30ec1152fcabf0f34f49194.tar.gz mailman-d0eff3c214b4940cb30ec1152fcabf0f34f49194.tar.zst mailman-d0eff3c214b4940cb30ec1152fcabf0f34f49194.zip | |
| -rw-r--r-- | src/mailman/bin/docs/master.txt | 2 | ||||
| -rw-r--r-- | src/mailman/bin/master.py | 12 | ||||
| -rw-r--r-- | src/mailman/testing/helpers.py | 8 |
3 files changed, 16 insertions, 6 deletions
diff --git a/src/mailman/bin/docs/master.txt b/src/mailman/bin/docs/master.txt index 2c396d8aa..f44b25214 100644 --- a/src/mailman/bin/docs/master.txt +++ b/src/mailman/bin/docs/master.txt @@ -9,7 +9,7 @@ just a wrapper around the real queue runner watcher script called master.py. >>> from mailman.testing.helpers import TestableMaster -Start the master in a subthread. +Start the master in a sub-thread. >>> master = TestableMaster() >>> master.start() diff --git a/src/mailman/bin/master.py b/src/mailman/bin/master.py index 99555d890..910bad3e6 100644 --- a/src/mailman/bin/master.py +++ b/src/mailman/bin/master.py @@ -400,6 +400,13 @@ class Loop: log.debug('[%d] %s', pid, spec) self._kids.add(pid, info) + def _pause(self): + """Sleep until a signal is received.""" + # Sleep until a signal is received. This prevents the master from + # existing immediately even if there are no qrunners (as happens in + # the test suite). + signal.pause() + def loop(self): """Main loop. @@ -407,10 +414,7 @@ class Loop: and configured to do so. """ log = logging.getLogger('mailman.qrunner') - # Sleep until a signal is received. This prevents the master from - # existing immediately even if there are no qrunners (as happens in - # the test suite). - signal.pause() + self._pause() while True: try: pid, status = os.wait() diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index 7c225d788..a54e26c82 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -140,6 +140,12 @@ class TestableMaster(Master): self.thread.daemon = True self._started_kids = None + def _pause(self): + """See `Master`.""" + # No-op this because the tests generally do not signal the master, + # which would mean the signal.pause() never exits. + pass + def start(self, *qrunners): """Start the master.""" self.start_qrunners(qrunners) @@ -162,7 +168,7 @@ class TestableMaster(Master): try: os.kill(pid, 0) starting_kids.remove(pid) - except OSError, error: + except OSError as error: if error.errno == errno.ESRCH: # The child has not yet started. pass |
