Advertisement
cymplecy

Untitled

Apr 12th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 0.75 KB | None | 0 0
  1.         lastTimeSinceLastSleep = time.time()
  2.         self.sleepTime = 0.1
  3.         while not self.stopped():
  4.             loopTime = time.time() - lastTimeSinceLastSleep
  5.             if loopTime < self.sleepTime:
  6.                 time.sleep(self.sleepTime-(time.time() - lastTimeSinceLastSleep)) # be kind to cpu  :)
  7.                 lastTimeSinceLastSleep = time.time()
  8.  
  9. should have been
  10.         lastTimeSinceLastSleep = time.time()
  11.         self.sleepTime = 0.1
  12.         while not self.stopped():
  13.             loopTime = time.time() - lastTimeSinceLastSleep
  14.             if loopTime < self.sleepTime:
  15.                 time.sleep(self.sleepTime-(time.time() - lastTimeSinceLastSleep)) # be kind to cpu  :)
  16.             lastTimeSinceLastSleep = time.time()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement