Dictionary inserts and threads
Martin P. Hellwig
mhellwig at xs4all.nl
Sat Jan 27 11:33:44 EST 2007
Hi all,
I'm thinking to speed up a process, I like to use multiple threads to
get data fractions from multiple servers and place those data fragments
into a local dictionary for further processing, the dictionary will look
like this:
self.dic = {'thread_a':dict(),
'thread_b':dict()}
The fragments will not overlap each other, since they will be
subdictionaries within the dictionary, though it would be possible that
multiple threads do something like this at the same time:
self.dic['thread_a'] = data_from_a()
and
self.dic['thread_b'] = data_from_b()
I assume that this is not a problem, but since assuming something gives
a lot of room for screw-ups I rather ask beforehand if I should except
all kinds of troubles when multiple threads update 'at the same time' a
dictionary or that I should lock the dictionary, for each update?
Thanks for your insights.
--
mph
More information about the Python-list
mailing list