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

Discussion in 'Python' started by Gabriel Rossetti, Apr 25, 2008.

  1. Hello,

    I'm having some trouble with the Queue class, for some reason, if I do
    this (ch == ) :

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

    where the output is :

    '\x02'
    0

    why isn't the character/string being put it in the queue?

    Thank you,
    Gabriel
     
    Gabriel Rossetti, Apr 25, 2008
    #1
    1. Advertising

  2. Gabriel Rossetti

    sturlamolden Guest

    On Apr 25, 4:38 pm, Gabriel Rossetti
    <> wrote:
    > Hello,
    >
    > I'm having some trouble with the Queue class, for some reason, if I do
    > this (ch == ) :
    >
    > q = Queue.Queue(0)
    > repr(ch)
    > q.put(ch, True)
    > len(q.queue)


    >>> from Queue import Queue
    >>> q = Queue(0)
    >>> s = '\x02'
    >>> q.put(s,True)
    >>> len(q.queue)

    1
     
    sturlamolden, Apr 25, 2008
    #2
    1. Advertising

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

    Arimaz SA
    Av. du 24 Janvier 11
    Ateliers de la Ville de Renens, Atelier 5
    1020 Renens, Switzerland
    www.mydeskfriend.com
    Mob: +41-(0)79-539-0069
    Tel: +41-(0)21-566-7343



    sturlamolden wrote:
    > On Apr 25, 4:38 pm, Gabriel Rossetti
    > <> wrote:
    >
    >> Hello,
    >>
    >> I'm having some trouble with the Queue class, for some reason, if I do
    >> this (ch == ) :
    >>
    >> q = Queue.Queue(0)
    >> repr(ch)
    >> q.put(ch, True)
    >> len(q.queue)
    >>

    >
    >
    >>>> from Queue import Queue
    >>>> q = Queue(0)
    >>>> s = '\x02'
    >>>> q.put(s,True)
    >>>> len(q.queue)
    >>>>

    > 1
    >
    >
    >
    >

    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....
     
    Gabriel Rossetti, Apr 25, 2008
    #3
  4. Gabriel Rossetti

    Jerry Hill Guest

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

    On Fri, Apr 25, 2008 at 11:11 AM, Gabriel Rossetti
    <> 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
     
    Jerry Hill, Apr 25, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Russell Warren

    Is Queue.Queue.queue.clear() thread-safe?

    Russell Warren, Jun 22, 2006, in forum: Python
    Replies:
    4
    Views:
    724
    Russell Warren
    Jun 27, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,236
    Smokey Grindel
    Dec 2, 2006
  3. bdb112
    Replies:
    45
    Views:
    1,420
    jazbees
    Apr 29, 2009
  4. Kris
    Replies:
    0
    Views:
    535
  5. Daniish
    Replies:
    2
    Views:
    267
    Thomas 'PointedEars' Lahn
    Jun 13, 2008
Loading...

Share This Page