Queue cleanup

EW ericwoodworth at gmail.com
Wed Aug 11 13:26:42 EDT 2010


On Aug 11, 1:18 pm, Paul Rubin <no.em... at nospam.invalid> wrote:
> EW <ericwoodwo... at gmail.com> writes:
> > I also might have different consumer threads do
> > different tasks (for example one might write to a log and one might
> > write to SQL) so that again means I can't plan for a set ratio of
> > consumers to producers....  So it's unknown.
>
> > So this means that instead of having 1 Queue that all the producers
> > put to and that all the consumers get from I actually have 1 Queue per
> > producer thread
>
> That doesn't sound appropriate.  Queues can have many readers and many
> writers.  So use one queue per task (logging, SQL, etc), regardless of
> the number of producer or consumer threads.  Any producer with an SQL
> request sends it to the SQL queue, which can have many listeners.  The
> different SQL consumer threads listen to the SQL queue and pick up
> requests and handle them.

I thought about doing it that way and I could do it that way but it
still seems like there should be a way to clean up Queues on my own.
If I did it this way then I guess I'd be relying on garbage collection
when the script ended to clean up the Queues for me.

What if I want to clean up my own Queues?  Regardless of the specifics
of my current design, I'm just generally curious how people manage
cleanup of their Queues when they don't want them any more.



More information about the Python-list mailing list