[issue11987] queue.Queue.put should acquire mutex for unfinished_tasks

patrick vrijlandt report at bugs.python.org
Wed May 4 08:09:23 CEST 2011


patrick vrijlandt <patrick.vrijlandt at gmail.com> added the comment:

I agree. Please close the ticket.

Thanks,

Patrick

2011/5/3 Raymond Hettinger <report at bugs.python.org>

>
> Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
>
> > This line should be protected by acquiring the all_tasks_done lock.
>
> All of three of the condition variables share the same underlying lock.
>  The increment occurs only with the lock has been acquired.
>
> > Theoretically, the increment could occur somewhere during task_done()!
>
> I don't understand what you mean.  The semantics of task_done() method
> implies that the count gets decremented.
>
> > Personally, I would like the increment to occur *before*
> > instead of *after* _put().
>
> There may be some merit to this but I don't see how it matters much since
> both occur within the context of the same lock being held.  A user defined
> method can still add or subtract any number it wants from the unfinished
> task count.  The result of +1 -5 is the same as -5 +1.
>
> I'm reluctant to change the order though because the code is already
> published and some user's _put code may be inspecting the unfinished tasks
> count.  I wouldn't want to break that code without good reason.
>
> ----------
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue11987>
> _______________________________________
>

----------
Added file: http://bugs.python.org/file21877/unnamed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11987>
_______________________________________
-------------- next part --------------
I agree. Please close the ticket.<div><br></div><div>Thanks,</div><div><br></div><div>Patrick<br><br><div class="gmail_quote">2011/5/3 Raymond Hettinger <span dir="ltr">&lt;<a href="mailto:report at bugs.python.org">report at bugs.python.org</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
Raymond Hettinger &lt;<a href="mailto:raymond.hettinger at gmail.com">raymond.hettinger at gmail.com</a>&gt; added the comment:<br>
<div class="im"><br>
&gt; This line should be protected by acquiring the all_tasks_done lock.<br>
<br>
</div>All of three of the condition variables share the same underlying lock.  The increment occurs only with the lock has been acquired.<br>
<div class="im"><br>
&gt; Theoretically, the increment could occur somewhere during task_done()!<br>
<br>
</div>I don&#39;t understand what you mean.  The semantics of task_done() method implies that the count gets decremented.<br>
<div class="im"><br>
&gt; Personally, I would like the increment to occur *before*<br>
&gt; instead of *after* _put().<br>
<br>
</div>There may be some merit to this but I don&#39;t see how it matters much since both occur within the context of the same lock being held.  A user defined method can still add or subtract any number it wants from the unfinished task count.  The result of +1 -5 is the same as -5 +1.<br>

<br>
I&#39;m reluctant to change the order though because the code is already published and some user&#39;s _put code may be inspecting the unfinished tasks count.  I wouldn&#39;t want to break that code without good reason.<br>

<br>
----------<br>
<div><div></div><div class="h5"><br>
_______________________________________<br>
Python tracker &lt;<a href="mailto:report at bugs.python.org">report at bugs.python.org</a>&gt;<br>
&lt;<a href="http://bugs.python.org/issue11987" target="_blank">http://bugs.python.org/issue11987</a>&gt;<br>
_______________________________________<br>
</div></div></blockquote></div><br></div>


More information about the Python-bugs-list mailing list