Popular recipes tagged "producer"http://code.activestate.com/recipes/tags/producer/2009-01-28T07:23:40-08:00ActiveState Code RecipesQueue with tagged items (Python)
2009-01-28T07:23:40-08:00Jirka Vejrazkahttp://code.activestate.com/recipes/users/4168986/http://code.activestate.com/recipes/576632-queue-with-tagged-items/
<p style="color: grey">
Python
recipe 576632
by <a href="/recipes/users/4168986/">Jirka Vejrazka</a>
(<a href="/recipes/tags/consumer/">consumer</a>, <a href="/recipes/tags/producer/">producer</a>, <a href="/recipes/tags/queue/">queue</a>, <a href="/recipes/tags/tag/">tag</a>).
Revision 2.
</p>
<p>I needed multiple consumers to retrieve data from a queue fed by one producer. Could not find a good working code for that, so I implemented my own queue. Docstring should describe how this works.</p>
<p>Two notes:
1) my code uses multiprocessing code, but in this module, the Lock and Condition could be easily replaced with the same objects from the threading module
2) the attached test uses syntax for "nose" testing package, I did not convert it to doctest or UnitTest.</p>