[issue2149] Queue.maxsize, __init__() accepts any value as maxsize

Rafael Zanella report at bugs.python.org
Thu Feb 21 14:06:05 CET 2008


Rafael Zanella added the comment:

@gutworth: Since one of the main uses of Queue is with threads, I think
it *really* should acquire the mutex before changing the maxsize;

@amaury.forgeotdarc: Your patch makes the point of allowing the size to
be changed at some other place (e.g.: an attribute of an instance passed
as the maxsize), but as stated above I think (am not an expert) the
mutex really should be held before the maxsize change, another point:
using an instance on your patch a call to Queue.maxsize would return
something like:
"""
Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class C:
...   def __init(self): self.n = 1;
...   def __int__(self): return int(self.n);
...
>>> c = C()
>>> import Queue
>>> q = Queue.Queue(c)
>>> q.maxsize
<__main__.C instance at 0xb7c341ac>
>>>                                        
"""
wich would force to have a get() to the maxsize attribute;

I have added a diff;

Added file: http://bugs.python.org/file9478/queue_maxsize_3.diff

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2149>
__________________________________


More information about the Python-bugs-list mailing list