why does the following with Queue, q.put('\x02', True) not put it in the queue?

Jerry Hill malaclypse2 at gmail.com
Fri Apr 25 11:41:52 EDT 2008


On Fri, Apr 25, 2008 at 11:11 AM, Gabriel Rossetti
<gabriel.rossetti at mydeskfriend.com> wrote:
>  yes, if you do it that way (s = '\x02') it works, but I read the data from
> a file, and I that way it doesn't work....

It does work (using Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45)
[MSC v.1310 32 bit (Intel)] on win32)

import Queue
f = open('temp', 'w')
f.write('\x02')
f.close()

f = open('temp', 'r')
ch = f.read(1)
f.close()

print repr(ch)
q = Queue.Queue(0)
q.put(ch, True)
print len(q.queue)

prints the following:
'\x02'
1

Perhaps you could put together an example that actually shows the
behavior you're seeing.  I'm not super familiar with Queue.Queue
internals, but should you be accessing the undocumented q.queue (the
internal deque of the Queue instance) directly?  Shouldn't you be
using the documented q.qsize() interface instead?

-- 
Jerry



More information about the Python-list mailing list