How to initialize each multithreading Pool worker with an individual value?

Valery Khamenya khamenya at gmail.com
Wed Dec 1 08:52:30 EST 2010


Hi Dan,

> If you create in the parent a queue in shared memory (multiprocessing
> facilitates this nicely), and fill that queue with the values in your
> ports tuple, then you could have each child in the worker pool extract
> a single value from this queue so each worker can have its own, unique
> port value.

this port number is supposed to be used once, namely during
initialization. Quite usual situation with conections is so, that it
is a bit expensive to initiate it each time the connection is about to
be used. So, it is often initialized once and dropped only when all
communication is done.

In contrast, your case looks for me that you rather propose to
initiate the connection each time a new job comes from queue for an
execution.

Regards,
Valery



More information about the Python-list mailing list