title: (Python) Using threading to look for key input with getch
body: <p>I've been trying to write a piece of test code which will continually print "Running" until a key is pressed. I've tried to implement this by creating an additional thread (called thread1) that will listen for a keypress.</p>
  
  <p>When I run my code, the thread launches fine, and seems to execute properly until getch.getch() is called. While getch.getch() is waiting for a keypress, it seems to stop not only thread1, but also the main thread. </p>
  
  <p>How can I ensure that while thread1 listens for a keypress, the main thread keeps running?</p>
  
  <p>I'm using python 2.7 and getch 1.0 (<a href="https://pypi.python.org/pypi/getch" rel="nofollow">https://pypi.python.org/pypi/getch</a>).</p>
  
  <p>Here's my code:</p>
  
  <pre><code>import threading
  import time
  import getch
  
  class myThread (threading.Thread):
      def __init__(self, threadID, name, cont):
          threading.Thread.__init__(self)
          self.threadID = threadID
          self.name = name
          self.cont = cont
  
      def run(self):
          print "Starting " + self.name +"\n"
          print "waiting 2 seconds"
          time.sleep(2)
          char = getch.getch()
          print 'You pressed %s' % char
          cont.append(1)
          print "Terminating" + self.name
  
  cont = []
  
  thread1 = myThread(1, "Thread1", cont)
  
  thread1.start()
  
  while cont == []:
      print "Running"
      time.sleep(0.5)
  </code></pre>
  
  <p>It outputs this:</p>
  
  <pre><code>Starting Thread1
  Running
  
  waiting 2 seconds
  Running
  Running
  Running
  </code></pre>
  
  <p>And it stays there until I press a key</p>