Skip to main content

doeff-time

Provider-agnostic time effects for doeff.

Effects

  • Delay(seconds)
  • WaitUntil(target: datetime) (target must be timezone-aware)
  • GetTime()
  • GetMonotonic() — monotonic seconds (float); only differences are meaningful
  • ScheduleAt(time: datetime, program) (time must be timezone-aware) — answers the spawned Task; Wait(task) answers program's value, or raises its failure
  • SetTime(time: datetime) (for simulation handlers, time must be timezone-aware)

Conversions

  • epoch_ms_of(at: datetime) -> int — timezone-aware time → epoch milliseconds, floored by integer timedelta division (no float on the way). This is the one rounding for every stamp that is laid next to another stamp: two places rounding the same instant differently (round vs floor) make a write at 329.6 ms look 1 ms later than a read at 329.9 ms.

Handlers

  • async_time_handler() for asyncio runtimes
  • sync_time_handler() for blocking runtimes
  • sim_time_handler(start_time=...) for deterministic virtual time (start_time is timezone-aware datetime), or sim_time_handler(clock=SimClock(start)) when the caller wants to read or move the virtual clock outside the program (tests)

Shared contract (all three handlers)

tests/test_time_contract.hy runs the same deftests under each handler (:interpreters ["async" "sync" "sim"]): readings never go back, Delay(d) / WaitUntil(t) advance the clock by d / up to t (exactly on the virtual clock, with a small jitter bound on the wall clock), past targets return at once, other effects pass through, and ScheduleAt tasks run in time order and answer their program's value or failure through Wait. SetTime is simulation-only and stays out of the shared contract. Note: the scheduled program runs under the handlers outside the time handler, so it cannot itself perform time effects.

Virtual time contract (sim_time_handler)

  • Install inside scheduled(...) and outside every Spawn whose tasks sleep on it; spawned tasks inherit the handler and share one clock.
  • Time advances to the earliest pending wake-up only when no normal-priority task is runnable, so a task woken at t reads t however many scheduler steps it takes.
  • Wake-ups at the same instant resume in the order they were requested; the trace is identical on the Rust scheduler (the default) and the Python one (DOEFF_SCHEDULER=python).
  • The run ends when the root program returns, even while daemon services are still sleeping.
  • GetMonotonic() answers the virtual clock's POSIX timestamp.

Metadata

Release files for doeff-time 0.1.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 doeff-time 0.1.0
File Size Uploaded Provenance Actions
doeff_time-0.1.0.tar.gz 39.1 kB Without provenance Details for doeff_time-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for doeff-time 0.1.0
File Interpreter ABI Platform Actions
doeff_time-0.1.0-py3-none-any.whl Python 3 none any Details for doeff_time-0.1.0-py3-none-any.whl

Total release size: 58.8 kB

Release files / doeff_time-0.1.0.tar.gz

Download URL doeff_time-0.1.0.tar.gz
Size 39.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9b73a3079d2b78847e0d3f41da535995b309b3dedf5f8b29f550d28fd52f86ef
BLAKE2b-256 checksum
How to use checksums
7e6a81f669101191e02c72c57f1c0010cd855aedbad52179991489e15dfcc858
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / doeff_time-0.1.0-py3-none-any.whl

Download URL doeff_time-0.1.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b997992d6f6e9886414b75ccf308224b27319fe33e427a867d43b75e35d792c
BLAKE2b-256 checksum
How to use checksums
5746736b5e9c277cae1bede51b5ec066d30517e3d770e7157b65d251d1bd9a3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for doeff-time 0.1.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.1.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