Can I load and run modules inside threads....

G

groupstudy2001

..... and is it a good idea???

I am thinking of writing a controlling module - call it a postmaster if
you will - that will start submodules and pass them work via queues -
one input queue per module. The modules will send their results back to
the postmaster via its queue. The postmaster will then read the
incoming message and, if necessary, pass it on to another thread.

The problem is that I want the submodules NOT to be known by or part of
the original module. So I have to load them as the need is seen,
probably by name, and tie them to queues. Can anyone see a problem with
this or some good way to do it?

Maybe,

modname = ....... #Module name a variable
exec("import %s as mod" % modname)
module_input_queue = Queue.Queue()
new_thread = mod.classname(
my_queue, module_input_queue, parms)
new_thread.start()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top