Is there any way this queue read can possibly block?

J

John Nagle

def draininput(self) : # consume any queued input
try:
while True :
ch = self.inqueue.get_nowait() # get input, if any
except Queue.Empty: # if empty
return # done

"self.inqueue" is a Queue object. The intent here is to drain the
queue, then return. Is there any way this can possibly block or hang?
I wouldn't think so. Another thread is doing "put" operations,
but slowly, never more than 5 per second.

(It's working for me, but a user of a program of mine is having a problem.)

John Nagle
 
C

Carl Banks

def draininput(self) :  # consume any queued input
     try:
         while True :
             ch = self.inqueue.get_nowait()     # get input, if any
     except Queue.Empty:                                # if empty
         return                                 # done

"self.inqueue" is a Queue object.  The intent here is to drain the
queue, then return.  Is there any way this can possibly block or hang?

Yes, but it'll be waiting to acquire the semaphore which Queues
normally don't hold onto for long.


Carl Banks
 
J

John Nagle

That wasn't the problem. An incoherent bug report from a user
was the problem.

John Nagle
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top