Changeset 26
- Timestamp:
- 10/16/07 03:13:30 (1 year ago)
- Location:
- branches/2.0.5
- Files:
-
- 3 modified
-
documentation/guide.wiki (modified) (1 diff)
-
turbomail/pool.py (modified) (4 diffs)
-
turbomail/startup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0.5/documentation/guide.wiki
r23 r26 46 46 * `utf-8-qp` -- Configures utf-8 to use quoted-printable encoding. (Note: this is not a real character set and can only be used with !TurboMail. Note also that this setting reconfigures the global ''utf-8'' setting to use a different encoding and will effect other processes using this mechanism.) 47 47 * `mail.polling` (Default: ''False'') If enabled, configures the thread pool to poll every mail.interval seconds for new jobs. This may give performance benefits to the running application. The default behaviour is to create new threads as soon as work is enqueued, resulting in faster delivery, but greater initial load. 48 * `mail.testmode` (Default: ''False'') If enabled, configures TurboMail NOT to send any mail to the specified server. Enqueued mails will just sit in the queue. This is very useful for unit tests where no interaction with the environment should take place. 48 49 49 50 In debug mode, using a single thread with a maximum of one job can be advantageous. Having a single thread with a maximum of a single job limits !TurboMail to a single SMTP connection at a time and automatically disconnects after sending each message. -
branches/2.0.5/turbomail/pool.py
r24 r26 23 23 """ 24 24 25 def __init__(self, interval=10, threads=4, jobs=10, timeout=60, polling=False, **kw):25 def __init__(self, interval=10, threads=4, jobs=10, timeout=60, polling=False, testmode=False, **kw): 26 26 """Initialize the thread pool. 27 27 … … 44 44 as required, when work is enqueued. 45 45 @type polling: bool 46 47 @param testmode: Enable or disable the unit testing mode. 48 Disabled, no mail is actually sent but only 49 stored in the queue for later retrieval. 50 @type testmode: bool 46 51 """ 47 52 … … 56 61 self._timeout = timeout 57 62 self._polling = False 63 self._testmode = testmode 58 64 self._kw = kw 59 65 … … 85 91 else: 86 92 self._queue.put(work, block=block, timeout=timeout) 93 94 if self._testmode: 95 log.debug("Testmode enabled, not sending mail.") 96 return 87 97 88 98 optimum_threads = min(self._threads, math.ceil(self._queue.qsize() / float(self._jobs))) -
branches/2.0.5/turbomail/startup.py
r1 r26 47 47 debug=turbogears.config.get("mail.debug", False), 48 48 tls=turbogears.config.get("mail.tls", None), 49 polling=turbogears.config.get("mail.polling", None) 49 polling=turbogears.config.get("mail.polling", None), 50 testmode=turbogears.config.get("mail.testmode", False) 50 51 ) 51 52
