APScheduler模块scheduler.add_job传进函数不执行

写了一个小的爬虫,准备用APScheduler定时执行,add____job方法里传进去要执行的函数不执行,代码如下:

def sprider():
    ss = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    print(ss)
    setUp()
    infoLoad()
    writeExcel()
    print("The End! %s" % time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))

if __name__ == "__main__":

    scheduler = BackgroundScheduler()
    # scheduler.add_job(run ,'cron', hour='3-4', minute='*', second='*/900')
    scheduler.add_job(func=sprider , trigger = 'interval', minutes = 2, start_date='2018-4-25 10:55:00', end_date='2018-4-25 11:01:00')

    scheduler.start()
    print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime())) 

运行之后如图所示

图片说明

print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime())) 之后主程序退出,shceduler 也没有了
让主程序继续不退出,才能让shceduler 继续执行

函数传入格式是你的 文件名:函数名

主程序退出了, 我是在后面让主程序一直sleep. 不过应该投更优雅的解决方案, 只是我没有找到