async def zj_order(): current_time = time.strftime('%Y-%m-%d') # 获取购买过zj已经同步成功的用户orgid res_user_li = await path_call('./get_zj_user.dspy', {}) for users in res_user_li: user_orgid = users.get('orgid') await path_call('./zj_get_order.dspy', {{'orgid': user_orgid, 'beginTime': current_time, 'endTime': current_time}}) async def zj_bill(): billmonth = time.strftime('%Y-%m') paytime = time.strftime('%Y/%m/%d') # 获取购买过zj已经同步成功的用户orgid res_user_li = await path_call('./get_zj_user.dspy', {}) for users in res_user_li: user_orgid = users.get('orgid') await path_call('./zj_get_bill.dspy', {'orgid': user_orgid, 'billMonth': billmonth, 'payTime': paytime}) if __name__ == '__main__': executor = apscheduler.schedulers.asyncio.AsyncIOScheduler( timezone='Asia/Shanghai', job_defaults={ "misfire_grace_time": 3600, # 允许存在多久时间的任务数 "max_instances": 200, # 该定时任务允许最大的实例个数 "coalesce": False # 多个任务堆积,是否运行最新的 } ) executor.add_job( zj_order, trigger='interval', minutes=5, coalesce=False, misfire_grace_time=3600, args=[]) executor.add_job( zj_bill, trigger='cron', hour='8, 9', minute='30', coalesce=False, misfire_grace_time=3600, args=[]) executor.start() try: asyncio.get_event_loop().run_forever() except (KeyboardInterrupt, SystemExit): pass