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#test
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']]#諛⑸쾿1
runbool=[True]
asdf=0
def test():
    global asdf,runbool
    config['setting']['time']=datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")#諛⑸쾿2
    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.0.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.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: catchup-schedules-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 d18781141c378380403ff848a9f04ad85820b4f7e44a34db02a3b5b9ae105933
MD5 2334cdb6ba71c8e50af3458f181c9340
BLAKE2b-256 330ba2297d948516459526a415af202640c101c21797899d61b8757e1d8a9c64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for catchup_schedules-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e547302eeab4e08ab0f76e28f88edf5fe884733835bad91d189063f10d702c98
MD5 02c98fb1a7285000fd1440c9e26c2a65
BLAKE2b-256 2a2554ce2208543afd899d296817b4713fee2716bb3711b0784bf435ee21bb02

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