wall_rate.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import time
00004 
00005 class WallRate():
00006 
00007     def __init__(self, rate):
00008         self.rate = rate
00009         self.period = 1.0 / rate if rate > 0.0 else 0.0
00010         self.recorded_time = time.time() 
00011 
00012     def sleep(self):
00013         current_time = time.time()
00014         elapsed = current_time - self.recorded_time
00015         if self.period - elapsed > 0:
00016             time.sleep(self.period - elapsed)
00017         self.recorded_time = time.time()


bwi_tools
Author(s): Piyush Khandelwal
autogenerated on Fri Aug 28 2015 10:14:30