Why are my queues empty even though there are items in it?
Kayode Odeyemi
dreyemi at gmail.com
Tue Sep 20 15:51:23 EDT 2011
On Tue, Sep 20, 2011 at 7:42 PM, MRAB <python at mrabarnett.plus.com> wrote:
> On 20/09/2011 19:13, Kayode Odeyemi wrote:
>
> def transaction_queue(queue, item, timeout, block=False):
>> queue = multiprocessing.Queue()
>>
>
> This line creates a new empty queue, hiding the one which was passed in.
Removed.
>
>
> if item is not {} and timeout is not 0:
>>
>
> `not {}` has the value True, so `item is not {}` means `item is True`.
> The `is` checks for identity, not equality, so this is true only if `item`
> actually has the value True or 1 (and this is an implementation-dependent
> behaviour).
changed to:
if item != {} and timeout != None
>
>
> print "Items are {0}".format(item)
>> for i in range(len(item)):
>>
>
> You're trying to get as many items from the queue as there are items in
> the dict `item`, which looks wrong to me.
>
>
> try:
>> d = queue.get(block)
>> print d
>> except Empty:
>> print 'Fees queue empty at %s' % (i)
>> else:
>> return process(q=queue, i=d, t=timeout)
>> else:
>> print 'No item in the queue to get'
>>
>> Effected this. d has a result in the output (output below). So obviously,
it is not empty.
What I'm trying to do in the initial code is to have all items in the queue
evaluated at the
same time such that each leaves the queue for processing when its timeout
period has elapse.
>
>> Q: Why are my queues empty even though there are items in it?
>>
>> What makes you think there are items in it? You print out `item`, which
> is not the queue.
>
I've made these changes but the queue still appears empty
None put to queue
{u'status': u'pending', u'timeout': 3}
empty queue
None put to queue
{u'status': u'pending', u'timeout': 5}
empty queue
Why 'empty queue' in process()? Also, why "None put to queue" since d
confirms
the items in the queue?
--
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110920/ccd01af3/attachment-0001.html>
More information about the Python-list
mailing list