Skip to main content

Suspend the execution of your program for a given amount of time. This works similarly to time.sleep, but uses your computers timestamp to track time, versus a counter.

For example, traditionally using time.sleep(3600), will pause the program for 60 minutes. If your computer goes into standby mode during minute one, and wakes up several hours later, your program will continue to be paused for 59 minutes.

On the other hand, with pause.seconds(3600), if your computer goes into standby mode for several hours, the program will continue immediately after the machine wakes back up since the minimum amount of time has passed since the pause was started.

How it works

When you create a pause, it will determine what the end time of that pause should be. Then a loop will be started that will continually check the current time against the end time. When the current time is equal or greater than the end time, the method will allow your program can resume.

Precision

The precision should be within 0.001 of a second, however, this will depend on how precise your system sleep is and other performance factors.

This module computes the pause duration between now and the future date, and then sleeps for half of this duration. After this time, it recomputes the new pause duration, repeating this process until the desired time is reached.

Install

Download the source code and run the following command:

sudo python ./setup.py install

Or, without downloading, install with pip:

sudo pip install pause

Examples:

Pause for half a second:

import pause
pause.milliseconds(500)

Or:

import pause
pause.seconds(0.5)

Pause for 1 minute:

import pause
pause.minutes(1)

Pause for 2 days:

import pause
pause.days(2)

Pause until a unix time, with millisecond precision:

import pause
pause.until(1370640569.7747359)

Pause using datetime:

import pause, datetime
dt = datetime.datetime(2013, 6, 2, 14, 36, 34, 383752)
pause.until(dt)

Functions

  • days(num)

    Pause for this many days

  • hours(num)

    Pause for this many hours

  • milliseconds(num)

    Pause for this many milliseconds

  • minutes(num)

    Pause for this many minutes

  • seconds(num)

    Pause for this many seconds

  • time(num)

    Same as PauseFor.seconds()

  • until(time)

    Pause your program until a specific end time. ‘time’ is either a unix timestamp in seconds (i.e. seconds since Unix epoch) or datetime object

  • weeks(num)

    Pause for this many weeks

Release files for pause 0.3

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

Source distribution (sdist)

Source distribution for pause 0.3
File Size Uploaded
pause-0.3.tar.gz 4.4 kB Details

Release files / pause-0.3.tar.gz

Download URL pause-0.3.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
82284ec6213376f718a86a51cf1df04eaa77ce85e349bff63c0071e7db33daba
BLAKE2b-256 checksum
How to use checksums
9f7fe48f80883c7a74a3303d0a62f1d48b3f6a097420ad9eda23e8fc6e07be2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file

0.2

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

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