Skip to main content

Create non-blocking scheduled tasks.

Project description

Schedules - Create non-blocking scheduled tasks.

Installation

Use the package manager pip to install schedules.

pip install schedules

Usage

Timer

Here is a simple timer scheduled task example.

After 3 days, 1 hour, 30 minutes and 10 seconds task will execute.

import schedules

# example task

def task(argument):
    print(argument)

# initialize a timer

timer = schedules.timer()

# Start the timer.

# "repeat=True" means the task not execute only once,
# it will execute every 3 days, 1 hour, 30 minutes and 10 seconds infinite times.

timer.day(3).hour(1).minute(30).second(10).start(target=task, args=("Example",), repeat=True)

If the task is asynchronous, You can do this:

import schedules

# example task

async def task(argument):
    print(argument)

# initialize a timer

timer = schedules.timer()

# Start the timer.

timer.day(3).hour(1).minute(30).second(10).start(target=task, args=("Example",), asynchronous=True)

Every

If you don't want the task to execute at a certain time, you can use every.

Every time the minutes are 0 (every new hour), task will execute.

import schedules

# example task

def task(argument):
    print(argument)

# initialize "every"

every = schedules.every()

# Start the timer.

# "repeat=True" means the task not execute only once,
# it will execute every time the minutes are 0 (every new hour) infinite times.

every.minute(0).start(target=task, args=("Example",), repeat=True)

# This code will execute the task at 2:30pm and 10 seconds everyday:

every.hour(14).minute(30).second(10).start(target=task, args=("Example",), repeat=True)

If the task is asynchronous, You can do this:

import schedules

# example task

async def task(argument):
    print(argument)

# initialize "every"

every = schedules.every()

# Start the timer.

every.hour(14).minute(30).second(10).start(target=task, args=("Example",), asynchronous=True)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

schedules-1.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

schedules-1.3-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file schedules-1.3.tar.gz.

File metadata

  • Download URL: schedules-1.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.9

File hashes

Hashes for schedules-1.3.tar.gz
Algorithm Hash digest
SHA256 855621d01996ad3303dea930955ad9cd7c0841e848fcf6f52aa4415b16944d98
MD5 8d40074c7e28fefa2f30d7295c6b96cd
BLAKE2b-256 10153847f540728d508be9697cf01d2a0837bc86fb2c2a44c97ed12f08814a8d

See more details on using hashes here.

File details

Details for the file schedules-1.3-py3-none-any.whl.

File metadata

  • Download URL: schedules-1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.9

File hashes

Hashes for schedules-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 36c2b57da125d275944d82c23eb59533b506253c8e08aefd302f51ae22ad3969
MD5 ccf93a11fc68c93d5943f7c95c37c2e9
BLAKE2b-256 17e0d45d57953c72d60e309e577ada4d1a6f4151de0a48a333b342439996baeb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page