import time import math while True: startTime = time.time() while time.time() - startTime < 0.8: fact = math.factorial(100) #// Or any other computation here print('factorial is', fact) print('time is ', time.time()) time.sleep(0.2)