To schedule a Python task, first decide whether you mean “after a delay,” “at a specific clock time,” or “repeatedly”—and whether it must survive a process restart. Use sched for a simple in-process queue, an asyncio event-loop timer for callbacks in an async app, or APScheduler 3.x for calendar-based and persistent jobs. For real-world clock times, use aware datetimes and specify UTC or a named time zone.
Choose a scheduler for the job
Python’s timers do not all use the same definition of time. A delay is measured with an elapsed-time clock; a calendar appointment is expressed as a wall-clock date and time. Choose based on the task’s timing, runtime, recurrence, and durability needs.
| Need | Approach | Clock and lifecycle |
|---|---|---|
| A small queue in one process | sched.scheduler |
Defaults to a monotonic clock; actions run in the process that created the scheduler. It can fall behind if actions take longer than the time available. Python sched documentation. |
| A delayed callback in an asyncio application | loop.call_later(delay, callback) |
The delay uses the event loop’s monotonic clock. The returned timer handle can be cancelled. Python asyncio event-loop documentation. |
| A callback at an event-loop deadline | loop.call_at(when, callback) |
when must use the same clock reference as loop.time(), not Unix epoch seconds or a datetime. Python asyncio event-loop documentation. |
| A one-time or recurring calendar job | APScheduler 3.x with a date, interval, or cron trigger |
Choose the trigger for a single run, fixed interval, or selected wall-clock times. APScheduler 3.x user guide. |
| A recurring schedule that should survive restarts | APScheduler 3.x with a persistent job store | Use stable job IDs during initialization and set a policy for jobs missed while the app was down. APScheduler 3.x user guide. |
Schedule a delay with Python’s sched module
Use sched when the task belongs to a small queue managed by the current process. Its default time function is time.monotonic, which is appropriate for measuring elapsed time rather than specifying a human calendar time.
import sched
import time
scheduler = sched.scheduler(time.monotonic, time.sleep)
def do_work():
print("running")
scheduler.enter(10, priority=1, action=do_work)
scheduler.run()
enter() schedules an event relative to when it is added. enterabs() accepts an absolute value expressed in the scheduler’s configured clock reference; it does not mean a date or time of day. Scheduling methods return an event object that can be cancelled. If an action runs long, queued events are delayed rather than discarded. Python’s sched documentation.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Schedule a delayed callback in asyncio
For an asynchronous application, use the running event loop’s timer methods rather than blocking the loop with time.sleep(). call_later() takes a delay in seconds and returns a handle you can cancel before it runs.
import asyncio
async def main():
loop = asyncio.get_running_loop()
handle = loop.call_later(10, print, "running")
# handle.cancel() can cancel it before it runs
await asyncio.sleep(11)
asyncio.run(main())
For a deadline expressed in the event loop’s own clock, calculate it from loop.time() and pass it to call_at():
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
when = loop.time() + delay
loop.call_at(when, callback)
Do not pass a Unix timestamp or a datetime to call_at(). As the asyncio documentation notes, “Event loop uses monotonic clocks to track time.” Timer callbacks may run up to one clock-resolution early, so these APIs are not hard real-time guarantees. Python asyncio event-loop documentation.
Represent current time and calendar targets safely
Use aware datetimes when a moment on the global timeline matters. Python’s datetime documentation recommends datetime.now(timezone.utc) for current UTC. A naive datetime has no time-zone information, and datetime methods may treat it as local time. Python datetime documentation.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
now_utc = datetime.now(timezone.utc)
now_in_new_york = datetime.now(ZoneInfo("America/New_York"))
Use zoneinfo.ZoneInfo for named civil time, such as a user’s location, instead of hard-coding today’s UTC offset. Time-zone rules can change when political authorities revise them, and the IANA database is periodically updated. Python zoneinfo documentation.
To turn a one-time target into a delay, first decide its time zone, then compare aware datetimes in that zone and handle the case where the target is already past:
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
delay = (target - now).total_seconds()
Feed the resulting delay to a timer only if keeping the process alive is sufficient. A sleeping timer does not preserve a job through a process exit, crash, or deployment.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Choose recurrence and daylight-saving behavior
APScheduler 3.x provides distinct triggers for different meanings of “repeat”: a date trigger for one run, an interval trigger for fixed elapsed intervals, and a cron trigger for selected times such as 9:00 a.m. each day. Choose a scheduler that fits the runtime; the APScheduler 3.x guide identifies AsyncIOScheduler for asyncio applications. These details are specific to APScheduler 3.x and should not be assumed to apply to other major versions. APScheduler 3.x user guide.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
“Every 24 hours” and “every day at 9:00 a.m. local time” are different requirements. The first is elapsed-time recurrence; the second follows civil time in a named time zone. At daylight-saving transitions, some local times are skipped or occur twice, so a cron job at such a time may run less or more often than expected. APScheduler’s cron documentation suggests using UTC or avoiding transition times when that variation is unacceptable. APScheduler 3.x cron trigger documentation.
Keep important jobs through restarts
A local in-process timer is not a durable queue. If work must remain scheduled after a restart, configure persistent scheduling or use an external scheduler suited to your deployment. With APScheduler 3.x persistent job stores, assign an explicit job ID and use replace_existing=True when adding jobs during application initialization; otherwise, initialization after a restart can add another copy of the job. APScheduler 3.x user guide.
Also decide what should happen when the application is down at a scheduled time. APScheduler offers misfire grace periods, which limit how late a job can still run, and coalescing, which can collapse multiple missed executions into one. Choose whether late work should run, be skipped after a cutoff, or be reduced to a single catch-up run based on what the task does.
Quick Recap
Common scheduling mistakes
- Passing wall-clock time to a monotonic API:
call_at()andsched.enterabs()expect values in their respective clock references, not a Unix timestamp or calendar datetime. - Using a naive datetime for a real-world appointment: attach UTC or a named time zone so the intended instant is clear.
- Confusing a fixed interval with a daily local time: decide whether the schedule follows elapsed duration or civil time before choosing a trigger.
- Expecting an in-process timer to survive downtime: use persistence or an external scheduler if the job must outlive the process.
- Ignoring missed-run policy: configure how late jobs may run and whether multiple missed executions should be coalesced.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools

