1

in my python bot i want use schedule module with a while loop. I want that every 60 seconds, while loop execute one iteration and not all loop. How can i do?

This is my code

 def job():
        count = 0
        variable1 = json.loads(requests.get(urloffertelampo).text)
        while count < (len(variable1['deals']['dr'])):
            ***example code to execute***
            count+=1

    schedule.every(60).seconds.do(job)

    while True:
        schedule.run_pending()
        time.sleep(1)
Carlo_PHP
  • 55
  • 1
  • 1
  • 5
  • Probably something involving an amalgamation of `yield` : https://stackoverflow.com/a/7972341/495157 and a timer https://www.tutorialspoint.com/timer-objects-in-python#:~:text=Timer%20objects%20are%20used%20to,()%20method%20timer%20is%20started. – JGFMK Jun 27 '20 at 09:55

1 Answers1

0

i have changed my function and use time.sleep() into loop

now it works!

Carlo_PHP
  • 55
  • 1
  • 1
  • 5