Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Schedule task keeps repeating and never stops

def refresh_page():
    driver.refresh()

time.sleep(2)
while True:
    if driver.find_element(By.CLASS_NAME, "mask2").is_displayed() == True:
        break
    schedule.every(1).minute.at(":00").do(refresh_page)
    
    schedule.run_pending()
    time.sleep(1)

I was expecting it to only run the schedule command once, well it did work when it was not on ":00" seconds but as soon as it hits ":00" it keeps doing the task whenever it’s possible to do so. Btw the element is not displayed and I checked it so it could not be that line that’s causing the problem (I think)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I think you need to put scheduling outside while loop, since it schedules multiple times:

def refresh_page():
    driver.refresh()

time.sleep(2)
schedule.every(1).minute.at(":00").do(refresh_page)
while True:
    if driver.find_element(By.CLASS_NAME, "mask2").is_displayed() == True:
        break
    
    schedule.run_pending()
    time.sleep(1)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading