Skip to main content
import sched2
sc = sched2.scheduler()

@sc.every(5)
def magic():
    ```python
    print("✨ Magic sparkles every five seconds! ✨")
    ```

sc.run()

The sched2 module extends the general purpose event scheduler sched from Python's standard library. sched2.scheduler is a subclass of sched.scheduler that adds new features such as the every and cron decorators. It's a practical tool for automating tasks that need to run repeatedly after certain time delays or at specific times.

Install

sched2 is available on PyPI.

pip install sched2

How to use

from urllib.request import urlopen
import sched2

# create the scheduler
sc = sched2.scheduler()

# we'll use this to remember the last IP address between runs
last_ip = None


@sc.every(10)  # seconds
def check_ip_address():
    global last_ip  # in case we need to update this

    # get the current IP address
    current_ip = urlopen("https://icanhazip.com/").read().decode("utf-8").strip()

    # if the IP address has changed
    if last_ip != current_ip:
        last_ip = current_ip

        # emit an event to notify the change
        sc.emit("ip_changed", kwargs={"new_ip": current_ip})

@sc.on("ip_changed")  # 'ip_changed' is the event name
def notify_ip_change(new_ip):  # 'new_ip' is the keyword argument passed to the event
    print(f'Your IP address has changed to {new_ip}')

@sc.cron("0 9 * * 1-5")  # every weekday at 9:00
def daily_greeting():
    print(f'Good morning, your current IP address is {last_ip}')

sc.run()

Source Code and Issues

The source code for sched2 is available on GitHub at github.com/medecau/sched2.

You can help improve sched2 by reporting any issues or suggestions on the issue tracker at github.com/medecau/sched2/issues.

Metadata

Release files for sched2 0.8.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sched2 0.8.3
File Size Uploaded Provenance Actions
sched2-0.8.3.tar.gz 7.6 kB Without provenance Details for sched2-0.8.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sched2 0.8.3
File Interpreter ABI Platform Actions
sched2-0.8.3-py3-none-any.whl Python 3 none any Details for sched2-0.8.3-py3-none-any.whl

Total release size: 13.9 kB

Release files / sched2-0.8.3.tar.gz

Download URL sched2-0.8.3.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1c45c115264adf63001104cdb17e90dea5ca602b5edde097559516a462f0519a
BLAKE2b-256 checksum
How to use checksums
4a9a054b346c4b2c746935626f696a037a9af21484706f0532f2cc378567a2cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.6

Release files / sched2-0.8.3-py3-none-any.whl

Download URL sched2-0.8.3-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad4667adc3be5cf0aeab5a2aef6c06dd67aaff855e79bb10f768d05b25ad3e1c
BLAKE2b-256 checksum
How to use checksums
1bda2e1b3d8d4cca83375fe1dd2a95e3d49afb7744445d00e478d823844a879b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.6

Security for sched2 0.8.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page