STINNER Victor added the comment:

"""
Return the number of items in the queue. Note, in multi-threading this mostly 
just serves as an approximation, and information from this doesn’t guarantee 
that a subsequent get() or put() will not block.
"""

I dislike this description. If I understand correctly, the issue is that 
someone must not rely on the size to check if the queue is empty or not. If I'm 
right, the doc must be more explicit. Something like:

"The size must not be used to check if get() or put() will block. Use 
get_nowait() and put_nowait(), or get() and put() in non-blocking mode 
(block=False)."

There is even a Wikipedia article on the bug :-)

https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use

(I'm not sure that it's exactly the same class of bug.)

----------
nosy: +haypo

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27624>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to