Skip to main content

Clockbound Python Library

This a library to consume ClockBound time error bounds in pure Python. Instead of operating on timestamps directly, you can call clockbound.now() to get a clockbound.TimeBound object that represents the earliest and latest possible times according to ClockBound. You can then use two TimeBound objects to deconflict events from eachother.

This allows you to implement interesting algorithms that do an end-run around several distributed systems problems, similar to how Google uses TrueTime in Spanner.

Any system that uses chrony can use ClockBound, and therefore this library, to get time bounds with very low overhead. The error bounds will narrow as your chrony time source is improved, with the good results obtained by using the Amazon Time Sync Service NTP Service (automatically used on AWS EC2 instances). Going beyond that and using the PTP Hardware Clock will yield the best results.

Minimizing your NTP error is outside of the scope of this project, but you can expect the following bounds in practice:

  • PC with internet NTP: +/- 10-50 ms
  • EC2 using default Amazon Time Sync Service: +/- 500 µs - 2 ms
  • EC2 with PTP Hardware Clock: "+/- 40 µs"

API

To use this library, you need the ClockBound daemon running on your system. This library will not work without it providing time bounds via shared memory.

For most purposes, you can use the clockbound.now() function to get TimeBound objects from the default global Clockbound instance. This library will construct the global on first use.

import clockbound
from clockbound import TimeBound

tb: TimeBound = clockbound.now()
print(str(tb))

# Output:
# 2025-11-17T06:37:47.679501+00:00 ± 506 µs

TimeBound objects have the following properties:

  • earliest: (int) The earliest possible time in nanoseconds since the epoch.
  • latest: (int) The latest possible time in nanoseconds since the epoch.
  • error_ns: (int) The error in nanoseconds.
  • earliest_dt: (datetime tz-aware UTC) A convenience accessor to get the earliest time as a datetime rounded down to microseconds.
  • latest_dt: (datetime tz-aware UTC) A convenience accessor to get the latest time as a datetime rounded up to microseconds.
  • __str__(): A string representation with the error margin included.

Errors

All errors subclass clockbound.ClockboundError. There are error subclasses for finer grained error handling, but they are not exposed as part of the public API at this time.

You can get errors for the following reasons:

  • The daemon is not running or shared memory cannot be accessed.
  • ClockBound reports that the clock is not synchronized, and we cannot give out guaranteed time bounds.
  • The requested time is voided (past the void_after time). This should be rare in practice, but can happen if the daemon crashes or is really slow to restart. We cannot get fresh time bounds and the last known bounds are now invalid.

Performance

Calling clockbound.now() is acceptable fast, allowing 350,000 calls per second on a fairly modest consumer machine.

Metadata

Release files for clockbound 0.3.0

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

Source distribution (sdist)

Source distribution for clockbound 0.3.0
File Size Uploaded Provenance Actions
clockbound-0.3.0.tar.gz 4.8 kB Without provenance Details for clockbound-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 10.8 kB

Release files / clockbound-0.3.0.tar.gz

Download URL clockbound-0.3.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2bbbf6c8a96a90fcc09e097658f3cc5ec015f1c6002de4ee11d9cd8ea59b1cda
BLAKE2b-256 checksum
How to use checksums
90f8a7911ec26d122110a6a635d6b5df918a7181e4fcba076d2e0e1329ca6412
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / clockbound-0.3.0-py3-none-any.whl

Download URL clockbound-0.3.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80788887743e161bf082898b78292ae18bca3b73733c18f6f77ea784a4abfa02
BLAKE2b-256 checksum
How to use checksums
4e294195806221ccfc50502a524b868fd46cce57ee046cc68c042a7960d66e6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for clockbound 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

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