Could it be that one thread is calling write() before __init__() has had
time to initialize self.tempString? Try getting the lock before initializing
self.tempString, and synchronize the inialization of self.tempSTring, aka
__init__(self):
create lock
lock
try: self.tempString = ""
finally:
unlock
HTH,
Oliver
···
-----------------------------
From: Bala [mailto:blk@srasys.co.in]
I am redirecting sys.stdout to the string.In multiple thread trying =
to access the sys.stdout, an exception is throwing .
Attribute.error tempString is not an attribute like that...
Thanks In Advance...
import thread
class RedirectingStdOutToStringBuffer:
def __init__(self):
self.tempString =3D ""
self.chdThreadlock =3D thread.allocate_lock()
=20
def write(self, strStdOut):
self.chdThreadlock.acquire()
try:
self.tempString =3D self.tempString + strStdOut
finally:
self.chdThreadlock.release()