Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 #-------------------------------------------------------------------- 4 # Filname: lock.py 5 # Author: Mazhugin Aleksey 6 # Created: 2008/03/02 7 # ID: $Id: $ 8 # URL: $URL: $ 9 # Copyright: Copyright (c) 2008, Mazhugin Aleksey. 10 # License: BSD 11 #-------------------------------------------------------------------- 12 13 """ 14 Summary 15 16 Details... 17 """ 18 19 # Importing 20 #import XPyLIB.dbg as dbg ##@ 21 import XPyLIB 22 23 ##:LOGGING:start 24 import XPyLIB.xlogging as _xlog 25 from functools import wraps 26 _log=_xlog.getLogger(__name__) 27 _log.disabled=0 28 _log_u=_xlog.IndentFormatter.lvlup 29 _log_d=_xlog.IndentFormatter.lvldown 30 _log_r=_xlog.IndentFormatter.lvlreset 31 _log_w=_xlog.IndentFormatter.lvlwrap33 @wraps(fun) 34 def wrapper(*args, **kwds): 35 return _xlog.IndentFormatter.lvlwraplog(fun,_log)(*args, **kwds)36 return wrapper 37 ##:LOGGING:end 38 39 try: 40 import thread 41 import threading 42 except: 43 thread=None 44 45 # Start Implementation 46 47 #_lock is used to serialize access to shared data structures in this module. 48 #This needs to be an RLock because fileConfig() creates Handlers and so 49 50 _lock = None 5153 """ 54 Acquire the module-level lock for serializing access to shared data. 55 56 This should be released with _releaseLock(). 57 """ 58 global _lock 59 if (not _lock) and thread: 60 _lock = threading.RLock() 61 if _lock: 62 _lock.acquire()6365 """ 66 Release the module-level lock acquired by calling _acquireLock(). 67 """ 68 if _lock: 69 _lock.release()7072 """ 73 Static rlock class. 74 """ 75 80 81 @staticmethod10983 """ 84 Acquire a thread lock for serializing access to the level counter. 85 """ 86 ##dbg.fwriteln('IndentFormatter.createLock') ##@ 87 if thread: 88 srlock.__lock = threading.RLock() 89 else: 90 srlock.__lock = None91 92 @staticmethod94 """ 95 Acquire thread lock. 96 """ 97 ##dbg.fwriteln('IndentFormatter.acquire') ##@ 98 if srlock.__lock: 99 srlock.__lock.acquire()100 101 @staticmethod111 """ 112 Instance rlock class. 113 """ 114 119 120 @staticmethod148 149 # End Implemetation 150 151 #-DEBUG-START------------------------------------------------------------------- 152 158 159 #-DEBUG-END--------------------------------------------------------------------- 160 161 if __name__=='__main__': 162 _debug() 163122 """ 123 Acquire a thread lock for serializing access to the level counter. 124 """ 125 ##dbg.fwriteln('IndentFormatter.createLock') ##@ 126 if thread: 127 self.__lock = threading.RLock() 128 else: 129 self.__lock = None130 131 @staticmethod133 """ 134 Acquire thread lock. 135 """ 136 ##dbg.fwriteln('IndentFormatter.acquire') ##@ 137 if IndentFormatter.__lock: 138 IndentFormatter.__lock.acquire()139 140 @staticmethod142 """ 143 Release thread lock. 144 """ 145 ##dbg.fwriteln('IndentFormatter.release') ##@ 146 if IndentFormatter.__lock: 147 IndentFormatter.__lock.release()
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Fri Apr 25 22:27:39 2008 | http://epydoc.sourceforge.net |