SMALLp wrote:
... I need a tip on how to communicat4 between threads.
Typically inter-thread communication is done via Queue.Queue.
Look up the Queue module in your docs.

a "Simple" example:

    import Queue
    shared_work = Queue.Queue()
    combined_replies = Queue.Queue()
    ... [distributor]
        in loop:
             shared_work.put(something_to_do)
             ...
        for n in range(workers):
            shared_work.put(None) # tell everybody to stop
        for thread in workers:
            thread.join(worker) # wait til they all finish
    combined_replies.put(None) # tell service to stop
    thread.join(writer)    # wait til it is done.

    ... [workers]
             ...
             for work in iter(shared_work.get, None):
                  <do work>
                  combined_replies.put('whatever')
             ...
    ... [writer]
             for results in iter(combined_results.get, None):
                  <use results>

--Scott David Daniels
scott.dani...@acm.org

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to