threads / dictionaries

Cliff Wells LogiplexSoftware at earthlink.net
Wed Jan 15 15:59:10 EST 2003


On Wed, 2003-01-15 at 12:21, .d.hos wrote:
> Hello everybody,
> I have a mutlithreading script in which I would like to create a
> unique dictionary for each thread.
> 
> Currently, If thread 1 is writing to a dictionary, and thread 2
> returns in the middle of that process, thread 1's dictionary is
> overwritten with thread 2's entries. If I Space out the threads with
> the sleep() function long enough, each dictionary returns a unique
> dictionary - but that kinda kills the purpose of multithreading...?

Using sleep() for thread synchronization is suicidal.  Have you looked
at Queue?

It isn't clear what you are trying to accomplish.  Perhaps if you gave
some idea of what the dictionary is used for and where it is created
(global? in the thread? as an argument to the thread?) you would get
better help.  

> can i dynamically name each dictionary for each thread? I've tried
> using the thread id as the dictionary name - but to no avail...(could
> be my coding)

Could be.

-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308






More information about the Python-list mailing list