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.1.tar.gz (4.9 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.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: catchup-schedules-1.0.1.tar.gz
  • Upload date:
  • Size: 4.9 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.1.tar.gz
Algorithm Hash digest
SHA256 16b132dfb51984ed3c12911674b75d7e72b487359e2b0b935f37c64a7e77564d
MD5 f112fe654ea832faf52fd76d2ad5c4ba
BLAKE2b-256 b1bf782e9fc78b8675b6c8968e0f2e5f675832dc2fd929def1860bb555f8d20f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for catchup_schedules-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a3292cc459ca0a99360c7488e4ac8c15dc3f1f35f54d8dca42549c39f893c47
MD5 2bea4e2279c85b88d8939f21086f1c75
BLAKE2b-256 2535ff6dc3b4030507bfe03c987b990918eb8023307d69e9a108f7cc79c8f5d6

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