test_var="TEST"
class exLogging(logging.Logger):
cmdidDict[threading.currentThread()]="default"
def __init__(self, name):
logging.Logger.__init__(self, name)
cmdidDict[threading.currentThread()]="default"
return
def setCmdId(self, newCmdId): #threadsafe sync
for k,v in cmdidDict.items():
cmdidDict[threading.currentThread()]=newCmdId
test_var=newCmdId
obj=ContextFilter(test_var) #ContextFilter is another class
self.addFilter(obj)
self.info("in setcmdid")
I want the setCmdId function in the class to be threadsafe as this function individually will be called from various threads. By threadsafe I mean that I want setCmdId function to set values of CMDID differently in each different thread and once the thread is over CMDID should attain its global value. CMDID and cmdidDict[] are global variables. The problem is that CMDID values persist. Can anyone point me in the right direction ??