def synchronized(func):
"""Decorator for storage-access methods, which synchronizes on a threading
lock. The parent object must have 'is_closed' and '_sync_lock' attributes.
"""
@wraps(func)
def synchronized_wrapper(self, *args, **kwargs):
with self._sync_lock:
return func(self, *args, **kwargs)
return synchronized_wrapper
代碼是在whoosh/src/util.py中,我無法理解synchronized_wrapper的效果以及synchronized_wrapper(self,* args,** kwargs)中的參數來自哪裏。任何人都可以給我一些指點嗎?python:爲什麼在裝飾器中使用包裝?
http://stackoverflow.com/questions/308999/what-does-functools-wraps-do – lucemia