def make_runner(name, slice, range, once=False): # The runner name must be defined in the configuration. Only runner short # names are supported. runner_config = getattr(config, 'runner.' + name, None) if runner_config is None: print(_('Undefined runner name: $name'), file=sys.stderr) # Exit with SIGTERM exit code so the master won't try to restart us. sys.exit(signal.SIGTERM) class_path = runner_config['class'] try: runner_class = find_name(class_path) except ImportError: if os.environ.get('MAILMAN_UNDER_MASTER_CONTROL') is not None: print(_('Cannot import runner module: $class_path'), file=sys.stderr) traceback.print_exc() sys.exit(signal.SIGTERM) else: raise if once: # Subclass to hack in the setting of the stop flag in _do_periodic() class Once(runner_class): def _do_periodic(self): self.stop() return Once(name, slice) return runner_class(name, slice)
def make_runner(name, slice, range, once=False): # Several conventions for specifying the runner name are supported. It # 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.runner package. runner_config = getattr(config, 'runner.' + name, None) if runner_config is not None: # It was a shortcut name. class_path = runner_config['class'] elif name.startswith('.'): class_path = 'mailman.runners' + name else: class_path = name try: runner_class = find_name(class_path) except ImportError: if os.environ.get('MAILMAN_UNDER_MASTER_CONTROL') is not None: # Exit with SIGTERM exit code so the master watcher won't try to # restart us. print(_('Cannot import runner module: $class_path'), file=sys.stderr) traceback.print_exc() sys.exit(signal.SIGTERM) else: raise if once: # Subclass to hack in the setting of the stop flag in _do_periodic() class Once(runner_class): def _do_periodic(self): self.stop() return Once(name, slice) return runner_class(name, slice)
def __init__(self, slice=None, numslices=1): super(OutgoingRunner, self).__init__(slice, numslices) # We look this function up only at startup time. self._func = find_name(config.mta.outgoing) # This prevents smtp server connection problems from filling up the # error log. It gets reset if the message was successfully sent, and # set if there was a socket.error. self._logged = False self._retryq = config.switchboards['retry']
def __init__(self, slice=None, numslices=1): super().__init__(slice, numslices) # We look this function up only at startup time. self._func = find_name(config.mta.outgoing) # This prevents smtp server connection problems from filling up the # error log. It gets reset if the message was successfully sent, and # set if there was a socket.error. self._logged = False self._retryq = config.switchboards['retry']
def setUp(self): self._mlist = create_list('*****@*****.**') # Set personalized delivery. self._mlist.personalize = Personalization.individual # Make Anne a member of this mailing list. self._anne = subscribe(self._mlist, 'Anne', email='*****@*****.**') self._msg = mfs("""\ From: [email protected] To: [email protected] Subject: test """) self._deliverer = find_name(config.mta.outgoing) # Set the maximum transactions per connection. config.push( 'maxtrans', """ [mta] max_sessions_per_connection: 3 """) self.addCleanup(config.pop, 'maxtrans')