#636·schedule

夏令时转为冬令时导致调度程序停止

作者: kimdre创建于 2024年10月27日更新于 2025年10月31日

def run_async(func, loop: asyncio.AbstractEventLoop, *args): """ Wrapper to run async functions in the scheduler

:param func: The async function to run
:param loop: The event loop
:param args: The arguments to pass to the function
"""

logger.debug(f"Running async function: {func}")
loop.call_soon_threadsafe(loop.create_task, func(*args))

async def start_scheduler(loop: asyncio.AbstractEventLoop, message_publisher: MessagePublisher): """ Start the scheduler

:param message_publisher: The message publisher
:param loop: The event loop
"""

logger.info("Starting scheduler...")

# Health check job

schedule.every(5).seconds.do(run_async, write_health, loop)
schedule.run_all()

# Schedule normal jobs

schedule.every(15).minutes.do(run_async, check_100th_checkins, loop, message_publisher)

schedule.every().day.at("10:00").do(run_async, check_birthdays, loop, message_publisher)
schedule.every().day.at("10:15").do(run_async, check_inactive_midterm_members_premium, loop, message_publisher)
schedule.every().day.at("10:30").do(run_async, check_inactive_longterm_members_premium, loop, message_publisher)
schedule.every().day.at("10:45").do(run_async, check_active_members_weekend_only_premium, loop, message_publisher)
schedule.every().day.at("12:45").do(run_async, check_inactive_new_members_premium, loop, message_publisher)
schedule.every().day.at("13:00").do(run_async, check_inactive_members, loop, message_publisher)

logger.info("Scheduler started.")

# Create multiline string with scheduled job names, interval and next run time
jobs = "\n• ".join(

内容来源: dbader/schedule