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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • groupstudy2001@yahoo.co.uk

    #1

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


    ..... 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_qu eue = Queue.Queue()
    new_thread = mod.classname(
    my_queue, module_input_qu eue, parms)
    new_thread.star t()

Working...