You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

clock-time

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clock-time

Provide sleep(secs)/time_s() functions

1.0
pipPyPI
Maintainers
1

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() <https://docs.python.org/3/library/time.html#time.sleep>_ function already use this method.

time_s()

Return time as an integer number of seconds since the epoch <https://docs.python.org/3/library/time.html#epoch>_.

Usage

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

.. sourcecode:: python

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()

Keywords

sleep

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts