asyncio-pause


Nameasyncio-pause JSON
Version 0.5 PyPI version JSON
download
home_pagehttps://github.com/iAbadia/python-asyncio-pause
SummaryA timestamp-based sleep function for Python using asyncio.
upload_time2023-10-17 21:37:29
maintainer
docs_urlNone
authorJeremy Gillick - Inaki Abadia
requires_python
licenseLICENSE.txt
keywords sleep timestamp datetime asyncio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Python Asyncio Pause
====================

Based on https://github.com/jgillick/python-pause

Suspend the execution of your program for a given amount of time using asyncio. 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 <http://www.pip-installer.org/en/latest/>`_::

     sudo pip install asyncio-pause


Examples:
---------

Pause for half a second::

    import asyncio-pause
    await pause.milliseconds(500)

Or::

    import asyncio-pause
    await pause.seconds(0.5)

Pause for 1 minute::

    import asyncio-pause
    await pause.minutes(1)

Pause for 2 days::

    import asyncio-pause
    await pause.days(2)

Pause until a unix time, with millisecond precision::

    import asyncio-pause
    await pause.until(1370640569.7747359)

Pause using datetime::

    import asyncio-pause, datetime
    dt = datetime.datetime(2013, 6, 2, 14, 36, 34, 383752)
    await 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/iAbadia/python-asyncio-pause",
    "name": "asyncio-pause",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "sleep timestamp datetime asyncio",
    "author": "Jeremy Gillick - Inaki Abadia",
    "author_email": "none@none.com",
    "download_url": "https://files.pythonhosted.org/packages/e3/e5/99439bdcdfb788633f39ac259f7916130bd2fa6c02a18eb4369c42917b31/asyncio-pause-0.5.tar.gz",
    "platform": "osx",
    "description": "Python Asyncio Pause\n====================\n\nBased on https://github.com/jgillick/python-pause\n\nSuspend the execution of your program for a given amount of time using asyncio. This works similarly to ``time.sleep``, but uses your computers timestamp to track time, versus a counter.\n\nFor 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.\n\nOn 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.\n\nHow it works\n------------\n\nWhen 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.\n\nPrecision\n---------\n\nThe precision *should* be within 0.001 of a second, however, this will depend on how precise your system sleep is and other performance factors.\n\nThis 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.\n\nInstall\n-------\n\nDownload the source code and run the following command::\n\n    sudo python ./setup.py install\n\nOr, without downloading, install with `pip <http://www.pip-installer.org/en/latest/>`_::\n\n     sudo pip install asyncio-pause\n\n\nExamples:\n---------\n\nPause for half a second::\n\n    import asyncio-pause\n    await pause.milliseconds(500)\n\nOr::\n\n    import asyncio-pause\n    await pause.seconds(0.5)\n\nPause for 1 minute::\n\n    import asyncio-pause\n    await pause.minutes(1)\n\nPause for 2 days::\n\n    import asyncio-pause\n    await pause.days(2)\n\nPause until a unix time, with millisecond precision::\n\n    import asyncio-pause\n    await pause.until(1370640569.7747359)\n\nPause using datetime::\n\n    import asyncio-pause, datetime\n    dt = datetime.datetime(2013, 6, 2, 14, 36, 34, 383752)\n    await pause.until(dt)\n\n\nFunctions\n---------\n\n* days(num)\n    Pause for this many days\n\n* hours(num)\n    Pause for this many hours\n\n* milliseconds(num)\n    Pause for this many milliseconds\n\n* minutes(num)\n    Pause for this many minutes\n\n* seconds(num)\n    Pause for this many seconds\n\n* time(num)\n    Same as PauseFor.seconds()\n\n* until(time)\n    Pause your program until a specific end time.\n    'time' is either a unix timestamp in seconds (i.e. seconds since Unix epoch) or datetime object\n\n* weeks(num)\n    Pause for this many weeks\n",
    "bugtrack_url": null,
    "license": "LICENSE.txt",
    "summary": "A timestamp-based sleep function for Python using asyncio.",
    "version": "0.5",
    "project_urls": {
        "Homepage": "https://github.com/iAbadia/python-asyncio-pause"
    },
    "split_keywords": [
        "sleep",
        "timestamp",
        "datetime",
        "asyncio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b899a7fdfb011941218129e5128437600595d3fbe658b5f63747e7306fdb2c8",
                "md5": "a5676a31165dd22f3c9e4bf727eb4529",
                "sha256": "f407ec64c82c69bfd1097edce63c15796e53efd82d665d35cdc462126686030a"
            },
            "downloads": -1,
            "filename": "asyncio_pause-0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a5676a31165dd22f3c9e4bf727eb4529",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6450,
            "upload_time": "2023-10-17T21:37:27",
            "upload_time_iso_8601": "2023-10-17T21:37:27.352618Z",
            "url": "https://files.pythonhosted.org/packages/8b/89/9a7fdfb011941218129e5128437600595d3fbe658b5f63747e7306fdb2c8/asyncio_pause-0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e3e599439bdcdfb788633f39ac259f7916130bd2fa6c02a18eb4369c42917b31",
                "md5": "31158c4996ba03a63464971865a60bc1",
                "sha256": "c45ff06b33adb0405d25912246e66929629003d4c641d2cb8ec0fc2519cf2fb7"
            },
            "downloads": -1,
            "filename": "asyncio-pause-0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "31158c4996ba03a63464971865a60bc1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5020,
            "upload_time": "2023-10-17T21:37:29",
            "upload_time_iso_8601": "2023-10-17T21:37:29.120886Z",
            "url": "https://files.pythonhosted.org/packages/e3/e5/99439bdcdfb788633f39ac259f7916130bd2fa6c02a18eb4369c42917b31/asyncio-pause-0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-17 21:37:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "iAbadia",
    "github_project": "python-asyncio-pause",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "asyncio-pause"
}
        
Elapsed time: 0.12802s