title: Python: Queue.get() blocks code from checking socket connection
body: <p>I'm running a thread which grabs a message off a queue, sends it to a client, and receives confirmation. If the client disconnects, the thread catches the socket error and terminates. The issue is if the msgQ is empty, the thread never checks the socket connection. Is there a way to set this code up so even if the queue is empty, the socket is checked? (issue being, without a message, there is nothing to send) </p>
  
  <p>Do I need to send a special ping?pong! message if msgQ is empty (and check on the client whether the message is log data or a ping?)? Any help would be appreciated. </p>
  
  <pre><code>def run(self): 
      while not self._terminate: 
          try: 
              msgs = self.msgQ.get()
  
              self.sock.send(pickle.dumps(msgs))
              rdy = pickle.loads(self.sock.recv(2097152))
          except socket.error, EOFError: 
              print 'log socketmanager closing'
              self.terminate()
              break
          except Empty: pass
  </code></pre>