Log message for revision 78993: synchronize thread start/stop methods Changed: U Zope/trunk/lib/python/Products/MailHost/MailHost.py A Zope/trunk/lib/python/Products/MailHost/decorator.py
-=- Modified: Zope/trunk/lib/python/Products/MailHost/MailHost.py =================================================================== --- Zope/trunk/lib/python/Products/MailHost/MailHost.py 2007-08-19 11:58:08 UTC (rev 78992) +++ Zope/trunk/lib/python/Products/MailHost/MailHost.py 2007-08-19 14:51:00 UTC (rev 78993) @@ -20,6 +20,7 @@ import time import logging from cStringIO import StringIO +from threading import Lock import Acquisition import OFS.SimpleItem @@ -38,6 +39,7 @@ QueueProcessorThread from interfaces import IMailHost +from decorator import synchronized queue_threads = {} # maps MailHost path -> queue processor threada @@ -74,8 +76,10 @@ smtp_pwd='' smtp_queue = False smtp_queue_directory = '/tmp' + lock = Lock() - timeout=1.0 + # timeout=1.0 # unused? + manage_options=( ( @@ -187,6 +191,7 @@ self.smtp_pwd or None ) + @synchronized(lock) def _stopQueueProcessorThread(self): """ Stop thread for processing the mail queue """ @@ -200,6 +205,7 @@ del queue_threads[path] LOG.info('Thread for %s stopped' % path) + @synchronized(lock) def _startQueueProcessorThread(self): """ Start thread for processing the mail queue """ Added: Zope/trunk/lib/python/Products/MailHost/decorator.py =================================================================== --- Zope/trunk/lib/python/Products/MailHost/decorator.py (rev 0) +++ Zope/trunk/lib/python/Products/MailHost/decorator.py 2007-08-19 14:51:00 UTC (rev 78993) @@ -0,0 +1,30 @@ +############################################################################## +# +# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +""" +Decorator(s) + +$Id: MailHost.py 78992 2007-08-19 11:58:08Z andreasjung $ +""" + +def synchronized(lock): + """ Decorator for method synchronization. """ + + def wrapper(f): + def method(*args, **kw): + lock.acquire() + try: + return f(*args, **kw) + finally: + lock.release() + return method + return wrapper _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins