Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lastTimeSinceLastSleep = time.time()
- self.sleepTime = 0.1
- while not self.stopped():
- loopTime = time.time() - lastTimeSinceLastSleep
- if loopTime < self.sleepTime:
- time.sleep(self.sleepTime-(time.time() - lastTimeSinceLastSleep)) # be kind to cpu :)
- lastTimeSinceLastSleep = time.time()
- should have been
- lastTimeSinceLastSleep = time.time()
- self.sleepTime = 0.1
- while not self.stopped():
- loopTime = time.time() - lastTimeSinceLastSleep
- if loopTime < self.sleepTime:
- time.sleep(self.sleepTime-(time.time() - lastTimeSinceLastSleep)) # be kind to cpu :)
- lastTimeSinceLastSleep = time.time()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement