HappyDoc Generated Documentation | unidist/threadsafedict.py | ||||||||
---|---|---|---|---|---|---|---|---|---|
/ unidist / threadsafedict.py threadsafedict by Geoff Howland Dictionaries are extremely useful in sharing information in a threaded program, as any thread can update the dictionary, and be used by all threads. However when changing the dictionary, problems can occur as the operations are not atomic, and threads may step on each other's execution. This class extends UserDict to make it thread safe. There are still a number of other locking issues that need to be dealt with in a threaded environment, but gets and sets to the dictionary, and retrieving it's keys will be done in a thread safe manner. Key iteration just returns all keys in a sequence to avoid an extended lock. Expect large key stores to perform accordingly. This will be slower and potentially cause delays in access, by design.
|