diff options
| author | Barry Warsaw | 2008-09-29 21:48:19 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2008-09-29 21:48:19 -0400 |
| commit | af67970b37a00941d532de574d0cd9c05b207d69 (patch) | |
| tree | d1af18d6361ea5f22cc768e9c306f22023b6db56 /mailman/interfaces/runner.py | |
| parent | 20a97a4163774212ad9f16c5a2e3abcbf3ecf918 (diff) | |
| download | mailman-af67970b37a00941d532de574d0cd9c05b207d69.tar.gz mailman-af67970b37a00941d532de574d0cd9c05b207d69.tar.zst mailman-af67970b37a00941d532de574d0cd9c05b207d69.zip | |
Diffstat (limited to 'mailman/interfaces/runner.py')
| -rw-r--r-- | mailman/interfaces/runner.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/mailman/interfaces/runner.py b/mailman/interfaces/runner.py index d279c5e7a..28b15968c 100644 --- a/mailman/interfaces/runner.py +++ b/mailman/interfaces/runner.py @@ -29,3 +29,82 @@ class IRunner(Interface): def stop(): """Stop the queue runner on the next iteration through the loop.""" + + QDIR = Attribute('The queue directory. Overridden in subclasses.') + + SLEEPTIME = Attribute("""\ + The number of seconds this queue runner will sleep between iterations + through the main loop. If given, overrides + `config.QRUNNER_SLEEP_TIME` + """) + + def _one_iteration(): + """The work done in one iteration of the main loop. + + Can be overridden by subclasses. + + :return: The number of files still left to process. + :rtype: int + """ + + def _process_one_file(msg, msgdata): + """Process one queue file. + + :param msg: The message object. + :type msg: `email.message.Message` + :param msgdata: The message metadata. + :type msgdata: dict + """ + + def _clean_up(): + """Clean up upon exit from the main processing loop. + + Called when the queue runner's main loop is stopped, this should + perform any necessary resource deallocation. + """ + + def _dispose(mlist, msg, msgdata): + """Dispose of a single message destined for a mailing list. + + Called for each message that the queue runner is responsible for, this + is the primary overridable method for processing each message. + Subclasses, must provide implementation for this method. + + :param mlist: The mailing list this message is destined for. + :type mlist: `IMailingList` + :param msg: The message being processed. + :type msg: `email.message.Message` + :param msgdata: The message metadata. + :type msgdata: dict + :return: True if the message should continue to be queue, False if the + message should be deleted automatically. + :rtype: bool + """ + + def _do_periodic(): + """Do some arbitrary periodic processing. + + Called every once in a while both from the queue runner's main loop, + and from the runner's hash slice processing loop. You can do whatever + special periodic processing you want here. + """ + + def _snooze(filecnt): + """Sleep for a little while. + + :param filecnt: The number of messages in the queue the last time + through. Queue runners can decide to continue to do work, or + sleep for a while based on this value. By default, the base queue + runner only snoozes when there was nothing to do last time around. + :type filecnt: int + """ + + def _short_circuit(): + """Should processing be short-circuited? + + :return: True if the file processing loop should exit before it's + finished processing each message in the current slice of hash + space. False tells _one_iteration() to continue processing until + the current snapshot of hash space is exhausted. + :rtype: bool + """ |
