Skip to main content

Recurring

Build Status Coverage Status Documentation Status

This is a simple library for running a function or callable every N seconds. It's meant for applications that need to schedule small, self-contined callable(s) on a relatively long, potentially changing period . alive-checks, state snapshots, that sort of thing.

Use this if:

  • You want to call something periodically over the lifetime of your application.
  • You want to be able to change the time between calls.
  • You want or need to avoid the overhead of joining and starting a thread every time. (up to 1/5 of a second according to my sample-size of one machine under no other load)
  • The stuff you're going to call isn't going to destroy machines if it's killed abruptly at the end of the application's life.

This is probably not appropriate for your project if:

  • You're already using or likely will be using a fleshed-out concurrency framework.
  • You have many things you'd like to repeatedly schedule and run.
  • Your callables absolutely must execute some cleanup code to avoid disaster on kill.

This is not a library intended for top-level program composition.

Installation:

pip install recurring

Usage:

import recurring

def stuff():
    # do stuff ...

seconds_between_stuff = 30

job = recurring.job(stuff, seconds_between_stuff)
job.start()

# ...

seconds_between_stuff = 300000000 # this will be *from when rate is set*, not *from the next scheduled call*
job.rate = seconds_between_stuff

# ...

# stop making calls until start() is called again
job.stop()

# some time later ....
job.start()

# stop making calls permanently
job.terminate()
job.start() # raises RuntimeError
job.rate = 3000 # raises RuntimeError

Metadata

Release files for recurring 2.0.0

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

Built distribution (wheel)

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

Release files / recurring-2.0.0-py3-none-any.whl

Download URL recurring-2.0.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08d25a10182da31b0d8c7a6c0d199706d7703026dd30c451594ee46d14133e69
BLAKE2b-256 checksum
How to use checksums
356f4e2ffc435bfcee7bcb83bad0d8307bd45842baa0b080e1efa55e07cc595d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.0.0 This release

1 release file

1.0.1

1 release file

1.0.0

1 release file

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