Too many threads

mark.pelletier at asrcms.com mark.pelletier at asrcms.com
Fri Sep 17 09:25:47 EDT 2010


On Sep 17, 1:38 am, Ned Deily <n... at acm.org> wrote:
> In article <20100917052259.GA28... at cskk.homeip.net>,
>  Cameron Simpson <c... at zip.com.au> wrote:
>
>
>
>
>
> > On 16Sep2010 22:14, Ned Deily <n... at acm.org> wrote:
> > | In article <20100917043826.GA21... at cskk.homeip.net>,
> > |  Cameron Simpson <c... at zip.com.au> wrote:
> > |
> > | > On 16Sep2010 09:55, mark.pellet... at asrcms.com <mark.pellet... at asrcms.com>
> > | > wrote:
> > | > | For some reason, the tasks I put into my thread pool occasionally get
> > | > | run more than once.
> > | > |
> > | > | Here's the code:
> > | >
> > | > You need to post your _exact_ code. I had to change:
> > | >   from queue import Queue
> > | > into
> > | >   from Queue import Queue
> > | > So: _do_ you have a "queue" (lowercase) module? Is it buggy?
> > |
> > | The OP is probably using Python 3.
>
> > Ah, that explains the print(). Anyone know if print() is thread safe in
> > python 3?
>
> I vaguely recalled a similar problem and, on the second try, found it:
>
> http://bugs.python.org/issue6750
>
> Looks like that fix should have been in Python 3.1.2.
>
> --
>  Ned Deily,
>  n... at acm.org- Hide quoted text -
>
> - Show quoted text -

I was a little surprised at my problems, as I cribbed the code from

http://docs.python.org/py3k/library/queue.html?highlight=queue#queue.Queue.put

But in the end, yeah it does look like a thread-safe problem with
print.  I tried replacing the print statement by using another queue,
and it worked just fine.  Glad to know that it's fixed in 3.1.2; of
course, I am running 3.1.1.  Doesn't matter, the print statement was
just for demonstration purposes.  I'm actually going to put a
subprocess.getoutput() there.  Wonder if that's thread safe?

Thanks, Cameron and Ned



More information about the Python-list mailing list