source: products/vendor/Products.MailHost/current/src/Products/MailHost/decorator.py @ 3356

Last change on this file since 3356 was 3356, checked in by fenix, 12 years ago

Load 2.13.1 into vendor/Products.MailHost?/current.

  • Property svn:eol-style set to native
File size: 939 bytes
Line 
1##############################################################################
2#
3# Copyright (c) 2002 Zope Foundation and Contributors.
4#
5# This software is subject to the provisions of the Zope Public License,
6# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
7# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10# FOR A PARTICULAR PURPOSE.
11#
12##############################################################################
13"""
14Decorator(s)
15"""
16
17
18def synchronized(lock):
19    """ Decorator for method synchronization. """
20
21    def wrapper(f):
22        def method(*args, **kw):
23            lock.acquire()
24            try:
25                return f(*args, **kw)
26            finally:
27                lock.release()
28        return method
29    return wrapper
Note: See TracBrowser for help on using the repository browser.