Skip to main content

Provide sleep(secs)/time_s() functions

Project description

Introduction

Provide sleep(secs) / time_s() functions. Fix overflow bugs in CPython implementation so far (v3.14.0a1).

sleep(secs)

Use clock_nanosleep() with CLOCK_MONOTONIC to sleep. So that the sleep is not affected by system date/time jumps.

On CPython 3.11+, time.sleep() function already use this method.

time_s()

Return time as an integer number of seconds since the epoch.

Usage

Only provide source code distribution, user need to install the build toolchain. It can’t be compiled on platforms without clock_nanosleep().

try:
    from clock_time import sleep, time_s
except ImportError:
    from time import sleep, time_ns
    def time_s():
        return time_ns() // 1_000_000_000

sleep(secs)
t = time_s()

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clock_time-1.0.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file clock_time-1.0.tar.gz.

File metadata

  • Download URL: clock_time-1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for clock_time-1.0.tar.gz
Algorithm Hash digest
SHA256 8a17f2740e7c09f4f5e699de783a45ba86f05ab4faee4f5b2744bf083eb20ba6
MD5 01ebaed787bb36417e885b29d7261c43
BLAKE2b-256 085a1b73dc1658ecf0e6d0038cfcdcafa599af0fbc262f6ac1b90ff5d8b1cfff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page