Queue.Queue examples?

Skip Montanaro skip at pobox.com
Tue Jul 23 10:38:11 EDT 2002


    Dave> despite having read the manual, i'm still totally ignorant on the
    Dave> basic concept of Queue and how can it be used to safely pass
    Dave> objects between two (or more) threads. could someone enlighten me?

Suppose you have a Queue object:

    q = Queue.Queue()

In one thread you can execute:

    q.put(someobj)

In another thread you can execute:

    someobj = q.get()

-- 
Skip Montanaro
skip at pobox.com
consulting: http://manatee.mojam.com/~skip/resume.html





More information about the Python-list mailing list