diff options
Diffstat (limited to 'src/mailman/commands')
| -rw-r--r-- | src/mailman/commands/cli_aliases.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_conf.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_control.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_digests.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_help.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_import.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_info.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_inject.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_lists.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_members.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_qfile.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_status.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_unshunt.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_version.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_withlist.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/eml_confirm.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/eml_echo.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/eml_end.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/eml_help.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/eml_membership.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/tests/test_control.py | 58 |
21 files changed, 75 insertions, 23 deletions
diff --git a/src/mailman/commands/cli_aliases.py b/src/mailman/commands/cli_aliases.py index 76713555a..f48814854 100644 --- a/src/mailman/commands/cli_aliases.py +++ b/src/mailman/commands/cli_aliases.py @@ -17,11 +17,11 @@ """Generate Mailman alias files for your MTA.""" -from mailman import public from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.utilities.modules import call_name +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_conf.py b/src/mailman/commands/cli_conf.py index 67db4ac53..0a00f5006 100644 --- a/src/mailman/commands/cli_conf.py +++ b/src/mailman/commands/cli_conf.py @@ -21,10 +21,10 @@ import sys from contextlib import closing from lazr.config._config import Section -from mailman import public from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_control.py b/src/mailman/commands/cli_control.py index 5ba0b5427..846f4a5c6 100644 --- a/src/mailman/commands/cli_control.py +++ b/src/mailman/commands/cli_control.py @@ -23,11 +23,11 @@ import errno import signal import logging -from mailman import public from mailman.bin.master import WatcherState, master_state from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_digests.py b/src/mailman/commands/cli_digests.py index 3a4d6614f..151a9332c 100644 --- a/src/mailman/commands/cli_digests.py +++ b/src/mailman/commands/cli_digests.py @@ -19,12 +19,12 @@ import sys -from mailman import public from mailman.app.digests import ( bump_digest_number_and_volume, maybe_send_digest_now) from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.interfaces.listmanager import IListManager +from public import public from zope.component import getUtility from zope.interface import implementer diff --git a/src/mailman/commands/cli_help.py b/src/mailman/commands/cli_help.py index 9222cd00f..5d6372e51 100644 --- a/src/mailman/commands/cli_help.py +++ b/src/mailman/commands/cli_help.py @@ -17,8 +17,8 @@ """The 'help' subcommand.""" -from mailman import public from mailman.interfaces.command import ICLISubCommand +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_import.py b/src/mailman/commands/cli_import.py index 126c026d0..d9384b5bc 100644 --- a/src/mailman/commands/cli_import.py +++ b/src/mailman/commands/cli_import.py @@ -21,12 +21,12 @@ import sys import pickle from contextlib import ExitStack, contextmanager -from mailman import public from mailman.core.i18n import _ from mailman.database.transaction import transactional from mailman.interfaces.command import ICLISubCommand from mailman.interfaces.listmanager import IListManager from mailman.utilities.importer import Import21Error, import_config_pck +from public import public from zope.component import getUtility from zope.interface import implementer diff --git a/src/mailman/commands/cli_info.py b/src/mailman/commands/cli_info.py index fd6c83f88..46643ae1d 100644 --- a/src/mailman/commands/cli_info.py +++ b/src/mailman/commands/cli_info.py @@ -20,12 +20,12 @@ import sys from lazr.config import as_boolean -from mailman import public from mailman.config import config from mailman.core.api import API30, API31 from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.version import MAILMAN_VERSION_FULL +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_inject.py b/src/mailman/commands/cli_inject.py index acbc37d67..0255b71d2 100644 --- a/src/mailman/commands/cli_inject.py +++ b/src/mailman/commands/cli_inject.py @@ -19,12 +19,12 @@ import sys -from mailman import public from mailman.app.inject import inject_text from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.interfaces.listmanager import IListManager +from public import public from zope.component import getUtility from zope.interface import implementer diff --git a/src/mailman/commands/cli_lists.py b/src/mailman/commands/cli_lists.py index f5e6d724a..3a598ab05 100644 --- a/src/mailman/commands/cli_lists.py +++ b/src/mailman/commands/cli_lists.py @@ -17,7 +17,6 @@ """The 'lists' subcommand.""" -from mailman import public from mailman.app.lifecycle import create_list, remove_list from mailman.core.constants import system_preferences from mailman.core.i18n import _ @@ -32,6 +31,7 @@ from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.listmanager import IListManager, ListAlreadyExistsError from mailman.interfaces.template import ITemplateLoader from mailman.utilities.string import expand, wrap +from public import public from zope.component import getUtility from zope.interface import implementer diff --git a/src/mailman/commands/cli_members.py b/src/mailman/commands/cli_members.py index 476d1f77d..1eb6550d6 100644 --- a/src/mailman/commands/cli_members.py +++ b/src/mailman/commands/cli_members.py @@ -21,7 +21,6 @@ import sys from contextlib import ExitStack from email.utils import formataddr, parseaddr -from mailman import public from mailman.app.membership import add_member from mailman.core.i18n import _ from mailman.database.transaction import transactional @@ -31,6 +30,7 @@ from mailman.interfaces.member import ( AlreadySubscribedError, DeliveryMode, DeliveryStatus, MemberRole) from mailman.interfaces.subscriptions import RequestRecord from operator import attrgetter +from public import public from zope.component import getUtility from zope.interface import implementer diff --git a/src/mailman/commands/cli_qfile.py b/src/mailman/commands/cli_qfile.py index f6502f14a..c8d3ec84b 100644 --- a/src/mailman/commands/cli_qfile.py +++ b/src/mailman/commands/cli_qfile.py @@ -19,11 +19,11 @@ import pickle -from mailman import public from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.utilities.interact import interact from pprint import PrettyPrinter +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_status.py b/src/mailman/commands/cli_status.py index 6b4abe45e..b60ba8841 100644 --- a/src/mailman/commands/cli_status.py +++ b/src/mailman/commands/cli_status.py @@ -19,10 +19,10 @@ import socket -from mailman import public from mailman.bin.master import WatcherState, master_state from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_unshunt.py b/src/mailman/commands/cli_unshunt.py index 6bb1a9800..49b9c6e26 100644 --- a/src/mailman/commands/cli_unshunt.py +++ b/src/mailman/commands/cli_unshunt.py @@ -19,10 +19,10 @@ import sys -from mailman import public from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_version.py b/src/mailman/commands/cli_version.py index 4660087de..bc26d0115 100644 --- a/src/mailman/commands/cli_version.py +++ b/src/mailman/commands/cli_version.py @@ -17,9 +17,9 @@ """The Mailman version.""" -from mailman import public from mailman.interfaces.command import ICLISubCommand from mailman.version import MAILMAN_VERSION_FULL +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/cli_withlist.py b/src/mailman/commands/cli_withlist.py index 23250c1a5..42eb57cfc 100644 --- a/src/mailman/commands/cli_withlist.py +++ b/src/mailman/commands/cli_withlist.py @@ -23,13 +23,13 @@ import sys from contextlib import ExitStack, suppress from functools import partial from lazr.config import as_boolean -from mailman import public from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.interfaces.listmanager import IListManager from mailman.utilities.interact import DEFAULT_BANNER, interact from mailman.utilities.modules import call_name +from public import public from string import Template from traceback import print_exc from zope.component import getUtility diff --git a/src/mailman/commands/eml_confirm.py b/src/mailman/commands/eml_confirm.py index 6787b0987..425bb00e8 100644 --- a/src/mailman/commands/eml_confirm.py +++ b/src/mailman/commands/eml_confirm.py @@ -17,10 +17,10 @@ """The 'confirm' email command.""" -from mailman import public from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand from mailman.interfaces.subscriptions import ISubscriptionManager, TokenOwner +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/eml_echo.py b/src/mailman/commands/eml_echo.py index 67f917d3e..db340fda9 100644 --- a/src/mailman/commands/eml_echo.py +++ b/src/mailman/commands/eml_echo.py @@ -17,9 +17,9 @@ """The email command 'echo'.""" -from mailman import public from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/eml_end.py b/src/mailman/commands/eml_end.py index 82b66a1a6..c280cc52f 100644 --- a/src/mailman/commands/eml_end.py +++ b/src/mailman/commands/eml_end.py @@ -17,9 +17,9 @@ """The email commands 'end' and 'stop'.""" -from mailman import public from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/eml_help.py b/src/mailman/commands/eml_help.py index 4ca2d72a4..b4a39009a 100644 --- a/src/mailman/commands/eml_help.py +++ b/src/mailman/commands/eml_help.py @@ -17,11 +17,11 @@ """The email command 'help'.""" -from mailman import public from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand from mailman.utilities.string import wrap +from public import public from zope.interface import implementer diff --git a/src/mailman/commands/eml_membership.py b/src/mailman/commands/eml_membership.py index e658e7b58..22f26e24d 100644 --- a/src/mailman/commands/eml_membership.py +++ b/src/mailman/commands/eml_membership.py @@ -18,13 +18,13 @@ """The email commands 'join' and 'subscribe'.""" from email.utils import formataddr, parseaddr -from mailman import public from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand from mailman.interfaces.member import DeliveryMode, MemberRole from mailman.interfaces.subscriptions import ( ISubscriptionManager, ISubscriptionService) from mailman.interfaces.usermanager import IUserManager +from public import public from zope.component import getUtility from zope.interface import implementer diff --git a/src/mailman/commands/tests/test_control.py b/src/mailman/commands/tests/test_control.py index 7377c4666..4425b3411 100644 --- a/src/mailman/commands/tests/test_control.py +++ b/src/mailman/commands/tests/test_control.py @@ -64,6 +64,59 @@ def find_master(): return None +def kill_with_extreme_prejudice(pid=None): + # 2016-12-03 barry: We have intermittent hangs during both local and CI + # test suite runs where killing a runner or master process doesn't + # terminate the process. In those cases, wait()ing on the child can + # suspend the test process indefinitely. Locally, you have to C-c the + # test process, but that still doesn't kill it; the process continues to + # run in the background. If you then search for the process's pid and + # SIGTERM it, it will usually exit, which is why I don't understand why + # the above SIGTERM doesn't kill it sometimes. However, when run under + # CI, the test suite will just hang until the CI runner times it out. It + # would be better to figure out the underlying cause, because we have + # definitely seen other situations where a runner process won't exit, but + # for testing purposes we're just trying to clean up some resources so + # after a brief attempt at SIGTERMing it, let's SIGKILL it and warn. + if pid is not None: + os.kill(pid, signal.SIGTERM) + until = timedelta(seconds=10) + datetime.now() + while datetime.now() < until: + try: + if pid is None: + os.wait3(os.WNOHANG) + else: + os.waitpid(pid, os.WNOHANG) + except ChildProcessError: + # This basically means we went one too many times around the + # loop. The previous iteration successfully reaped the child. + # Because the return status of wait3() and waitpid() are different + # in those cases, it's easier just to catch the exception for + # either call and exit. + return + time.sleep(0.1) + else: + if pid is None: + # There's really not much more we can do because we have no pid to + # SIGKILL. Just report the problem and continue. + print('WARNING: NO CHANGE IN CHILD PROCESS STATES', + file=sys.stderr) + return + print('WARNING: SIGTERM DID NOT EXIT PROCESS; SIGKILLing', + file=sys.stderr) + if pid is not None: + os.kill(pid, signal.SIGKILL) + until = timedelta(seconds=10) + datetime.now() + while datetime.now() < until: + status = os.waitpid(pid, os.WNOHANG) + if status == (0, 0): + # The child was reaped. + return + time.sleep(0.1) + else: + print('WARNING: SIGKILL DID NOT EXIT PROCESS!', file=sys.stderr) + + class FakeArgs: force = None run_as_user = None @@ -171,7 +224,7 @@ class TestBinDir(unittest.TestCase): args_config = Configuration() args_config.load(self.args.config) self.assertFalse(os.path.exists(args_config.PID_FILE)) - os.wait() + kill_with_extreme_prejudice() def test_master_is_elsewhere_and_findable(self): with ExitStack() as resources: @@ -188,5 +241,4 @@ class TestBinDir(unittest.TestCase): # killable. We might have to wait until the process has started. master_pid = find_master() self.assertIsNotNone(master_pid, 'master did not start') - os.kill(master_pid, signal.SIGTERM) - os.waitpid(master_pid, 0) + kill_with_extreme_prejudice(master_pid) |
