Skip to main content

A robust scheduling module designed to catch up on periodic tasks that were skipped due to system pauses or downtime.

Project description

catchup-schedules

A Persistent Python Scheduler that Remembers Missed Events and Maintains its Cycle.

A robust scheduling module designed to catch up on periodic tasks that were skipped due to system pauses or downtime.

Example

import catchup_schedules

Example 1

import catchup_schedules
import datetime
time_example = [""] #or ["2025-10-08T19:15:17Z"]
def test():
    print("Hello World!")
catchup_schedules.run(test,"1m 30s",False,time_example)

Example 2

import catchup_schedules
import datetime
import configparser
import os
config = configparser.ConfigParser()
config.read(os.path.join(os.path.dirname(os.path.abspath(__file__)),'resourcenospec','setting.ini'), encoding="UTF-8")
daads = [config['setting']['time']]
runbool=[True]
asdf=0
def test():
    global asdf,runbool
    config['setting']['time']=datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
    print("test",config['setting']['time'],datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"))
    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)),'resourcenospec','setting.ini'), 'w', encoding='utf-8') as configfile:
        config.write(configfile)
    print(asdf)
    if asdf==4:
        runbool[0]=False
    else:
        asdf+=1
catchup_schedules.run(test,"2s ",False,True,daads,running=runbool)
print("end")

Install

https://pypi.org/project/catchup-schedules/

$ python -m pip install catchup-schedules

Parameter

catchup_schedules.run(Parameter)

Parameter Type Description Example
run_func callable The function to be executed repeatedly. test()
looptime str Sets the repeat interval (period). You can specify multiple values and units (w, d, h, m, s) separated by spaces. 1w, 3d, 2h, 5s, 10m 5s
cycle_type bool Determines the method for handling missed cycles. Sets when the next schedule should occur after code execution has been paused and resumed. True, False
- True (Maintain Cycle): Maintains the original period. It calculates the time the function should have last run, updates starttime to that point, and the next execution is scheduled looptime after this updated time.
- False (Start New Cycle): Updates starttime to the current time and starts a new cycle from now.
resume bool Determines whether to immediately execute run_func once upon starting the module if any schedules were missed while the code was paused. True, False
Note: This setting operates independently of the cycle_type setting. The function will execute when resume is True if any cycles were missed, regardless of the value of cycle_type.
starttime (Optional) list A list used to store and remember the previous execution time.
It must contain a string in the format of ["YYYY-MM-DDTHH:MM:SSZ"] or [""].
The default value is the current time if the variable is not passed, and it is also initialized to the current time if the variable's value is an empty string ([""]).
["2025-10-08T19:15:17Z"]
running (Optional) list A list used to control the execution state of a function.
It is expected to contain a single boolean value (True or False).
When the value is [True], the function continues execution. When it is [False], the function terminates and exits.
The default value is [True].
[True], [False]

Tip

The required datetime format is "%Y-%m-%dT%H:%M:%SZ".

#Example
starttime[0] = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")

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

catchup-schedules-1.0.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

catchup_schedules-1.0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file catchup-schedules-1.0.2.tar.gz.

File metadata

  • Download URL: catchup-schedules-1.0.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for catchup-schedules-1.0.2.tar.gz
Algorithm Hash digest
SHA256 18522a843a90f863a83bf8857f3c9446e6ff7aac1bb2c5df7063001eb719acd2
MD5 3c59831b899b729bf90a8228590ed334
BLAKE2b-256 6d94a9d2e8b5d8eb42a153c49abb8a15eef8470c95ac0bc1970abe3ef312802c

See more details on using hashes here.

File details

Details for the file catchup_schedules-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for catchup_schedules-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 337bc08ecb5a80967915ea32a2dd33df4682d9ff7873878e50852faaa1396f33
MD5 a806778c65a1c90162aaf8e5f69df808
BLAKE2b-256 462f02509f5aa9386ec83376f5cd1ac518fdc00444b602f9ee7efc1c401cdf44

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