title: Python2 : How to speed up Queue.get with timeout?
body: <p>I'm trying to write a fast event system for multiples threads using Queues.
  Each Thread has a stdin and wait for this one to be filled.</p>
  
  <p>So main part of my thread is like that :</p>
  
  <pre><code>class MyThread(threading.Thread):
      def __init__(self):
          threading.Thread.__init__(self)
          self.stdin = Queue.Queue()
          # Some code here
  
      def run(self):
          while True:
               try:
                   order = self.stdin.get(block=True,timeout=5)
                   if self.do(order) is False:
                       break
               except Queue.Empty:
                   pass
  
      def do(self,order):
          if order["txt"] == "quit":
              return False
          deltaTime = time.time() - order["time"]
          print("Message : "+str(order["txt"])+", DeltaTime : "+str(deltaTime))
          # Some code here
  </code></pre>
  
  <p>I would like to do fast multimedia opperations so I need a realy reactive system, but when I do some litle benchmark I got 50 ms of latence juste with that (on a 2.4 GHz Intel i7 processor)</p>
  
  <p>This is my benchmark code :</p>
  
  <pre><code>thread = MyThread()
  thread.start()
  thread.stdin.put({"txt": "test1", "time": time.time()})
  time.sleep(1)
  thread.stdin.put({"txt": "test2", "time": time.time()})
  time.sleep(1)
  thread.stdin.put({"txt": "test3", "time": time.time()})
  time.sleep(1)
  thread.stdin.put({"txt": "quit", "time": time.time()})
  thread.join()
  print("END")
  </code></pre>
  
  <p>And finaly I got that : </p>
  
  <pre><code>Message : test1, DeltaTime : 0.00104689598083
  Message : test2, DeltaTime : 0.0151479244232
  Message : test3, DeltaTime : 0.0292360782623
  END
  </code></pre>
  
  <p>This is about 20 ms but with all the program it's far to much for a real time application !
  Now when I try without the timeout it's much better :</p>
  
  <pre><code>Message : test1, DeltaTime : 6.69956207275e-05
  Message : test2, DeltaTime : 5.22136688232e-05
  Message : test3, DeltaTime : 5.79357147217e-05
  END
  </code></pre>
  
  <p>Is there any solution to speed up the Queue.get with keeping the timeout ?</p>
  
  <p>Thanks !</p>