title: How to stop a gevent micro thread when it in a while loop?
body: <p>I have a problem and the situation was like code as below. The target function(wait) was in a while loop or spent a huge time, so I want to kill the micro thread. How to kill the thread1?</p>
  
  <p><strong>Note</strong> : The micro-thread of user may be a CPU bound operation (for example a while loop without any IO operation.)</p>
  
  <pre><code>import gevent
  from gevent import Timeout
  
  def wait():
      while(1):
          pass
      print 'end'
  
  
  timer = Timeout(1).start()
  thread1 = gevent.spawn(wait)
  
  try:
      thread1.join(timeout=timer)
  except Timeout:
      print('Thread 1 timed out')
  </code></pre>
  
  <p>Both of <code>gevent.killall()</code> and <code>thread.kill()</code> requires the <code>thread scheduler</code> to run, they will not kill the thread as we expected.</p>