继续阅读:
- https://github.com/GrahamDumpleton/wrapt/tree/develop/blog
特别是:
- https://github.com/GrahamDumpleton/wrapt/blob/develop/blog/07-the-missing-synchronized-decorator.md
- https://github.com/GrahamDumpleton/wrapt/blob/develop/blog/08-the-synchronized-decorator-as-context-manager.md
然后,
wrapt模块包含
@synchronized此处描述的装饰器。
- https://pypi.python.org/pypi/wrapt
完整的实现足够灵活,可以执行以下 *** 作:
@synchronized # lock bound to function1def function1(): pass@synchronized # lock bound to function2def function2(): pass@synchronized # lock bound to Classclass Class(object): @synchronized # lock bound to instance of Class def function_im(self): pass @synchronized # lock bound to Class @classmethod def function_cm(cls): pass @synchronized # lock bound to function_sm @staticmethod def function_sm(): pass
class Object(object): @synchronized def function_im_1(self): pass def function_im_2(self): with synchronized(self): pass
有关更多信息和示例,请参见:
- http://wrapt.readthedocs.org/en/latest/examples.html
您还可以通过以下方式进行会议演讲:
- &t=1s)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)