multiprocessing.Pool, its queue, and pre-emption

Chris Angelico rosuav at gmail.com
Thu Sep 15 18:14:00 EDT 2011


On Fri, Sep 16, 2011 at 6:52 AM, John Ladasky <ladasky at my-deja.com> wrote:
> Suppose that I have a second, parallelizable, long-running task T2
> that I want to address in REAL TIME when the need arises.  Using Pool,
> is there a way for me to insert the chunks of T2 at the HEAD of the
> task queue, instead of at its TAIL?
>

That's a self-contradiction there. Even if you insert a task into the
head of the queue, it won't be addressed in real time; the only way to
do that would be to have a dedicated process, always ready to handle
the real-time events, or else some kind of interrupt system.

But if you just want them handled when there's a worker available,
what you're after is a priority queue system. I don't know if one
exists in Python already or not, but if not, it'd be a worthwhile
addition.

ChrisA



More information about the Python-list mailing list