def InterruptibleSleep(sleep_time):
 slept = 0.0
 epsilon = 0.0001
 thread = threading.currentThread()
 while (slept < (sleep_time - epsilon)):
  remaining = (sleep_time - slept)
  this_sleep_time = min(remaining, 0.5)
  time.sleep(this_sleep_time)
  slept += this_sleep_time
  if thread.exit_flag:
   return

def InterruptibleSleep ( sleep_time ) : slept = 0.0 epsilon = 0.0001 thread = threading . currentThread ( ) while ( slept < ( sleep_time - epsilon ) ) : remaining = ( sleep_time - slept ) this_sleep_time = min ( remaining , 0.5 ) time . sleep ( this_sleep_time ) slept += this_sleep_time if thread . exit_flag : return
puts thread to sleep .