Thread Safety
Clarence Gardner
clarence at netlojix.com
Sun Jan 28 00:41:12 EST 2001
Hello all,
I have a multithreaded program in which I use the following pattern in
various places, because I was pretty sure it was thread-safe. But since
I was just reading the thread about statcache, I thought I'd ask just to be
sure. The code is in a function that runs periodically and disposes of
accumulated work:
def Periodic():
global PendingDataStorage,PendingStatusUpdates
while 1:
time.sleep(10)
Data,PendingDataStorage = PendingDataStorage,[]
if Data:
StoreDataPoints(Data)
Data,PendingStatusUpdates = PendingStatusUpdates,[]
if Data:
SetErrorStatus(Data)
The code I'm talking about are the two binding statements, where
I bind to two names which form a tuple, rather than two statements,
which would certainly not be thread-safe.
Thanks,
--
Clarence Gardner
Software Engineer
NetLojix Communications
clarence at netlojix.com
More information about the Python-list
mailing list