Hi guys!
I’m trying to make a loop in a server module where the While loop will run all the time (this is required) but will have a delay of some time, say 5 seconds.
I decided to implement it the way I do locally in python 3 using time.sleep.
Server module code:
def getActualPrice(ticker):
while 1:
r = requests.get(f'https://api.binance.com/api/v3/ticker/price?symbol={ticker}')
price = r.json()['price']
time.sleep(5)
return price
But when starting the preview and executing this part of the code, the application just lagging and gives the following error: “anvil.server.TimeoutError: Server code took too long”
It seems to me that anvil simply does not support time.sleep and, accordingly, simply loops an infinite loop and hangs without paying attention to time.sleep (import time is present).
Who faced, is there a solution?