Is there a better way to run a python script periodically besides scheduler?

69 Views Asked by At

I have a python script that reads .csv files in a specific folder every x sec/min/hour automatically. I am trying to find better way(for performance and resources) to do it. The OS is Windows.

Example code:

import os
from apscheduler.schedulers.blocking import BlockingScheduler

def s_job():
    base_dir = "C:\\path"
    csv_files = os.listdir(base_dir)
    for csv_file in csv_files:
        #read csv file and import to sql server
        ......
        #delete csv file
        os.remove(f'{base_dir}\\{csv_file}')


scheduler = BlockingScheduler()
scheduler.add_job(s_job, 'interval', hours=1)
scheduler.start()

To be honest I know scheduler but I don't know what is the BlockingScheduler. So, there are many scheduler types I can use. Are there any resources where I can find information about these scheduler types?

Thanks.

0

There are 0 best solutions below