title: threading python bind several ports
body: <p>I want to do a simple thing: just bind two ports to wait for incoming connections and continous with the application code. This is the code.</p>
  
  <pre><code>import socket
  import threading
  import Queue
  
  q = Queue.Queue()
  q2 = Queue.Queue()
  
  def escucha_9003():
  
      s = socket.socket()
      s.bind(("localhost",9023))
      s.listen(10) 
      sc, address = s.accept()
      q.put(sc)
  
  
  
  def escucha_9004():
  
      s2 = socket.socket()
      s2.bind(("localhost",9024))
      s2.listen(10) 
      sc2, address2 = s2.accept()
      q.put(sc2)
  
  hilo = threading.Thread(target=escucha_9003).start()
  sc2=q.get()
  hilo2 = threading.Thread(target=escucha_9004).start()
  sc=q2.get()
  
  print "i never arrive here"
  </code></pre>
  
  <p>I need to get some parameters that are returned in each function. I use Queue library to do it.
  But the problem is that i want to keep working with the code and I never arrive to the line: print "i never arrive here". At least it is never printed.</p>
  
  <p>How need I do it to continue developing after launch those two threads and work with the incoming connections.</p>
  
  <p>Thank you very much</p>