So I stumbled upon an answer that almost satisfies my question.
In my case I want to fetch the status of my limit buy order in market for 5 seconds every 0.8 seconds or so. The code that I found looks like this:
import threading
def printit():
threading.Timer(0.8, printit).start()
print("Hello, World!")
and to run something for 5 seconds, one can do the following:
import time
t_end = time.time() + 5
while time.time() < t_end:
print('Hello World')
but combining those two like so, is not gonna work:
while time.time() < t_end:
printit()
So I am just wondering how I can make printit() run every 0.8 seconds for 5 seconds?