Skip to main content

Updated polling utility with many configurable options

Project description

Build Status PyPI PyPI

polling2

Never write another polling function again!

Documentation available at Read the Docs

You can install the package from Pypi

Polling2 is a powerful python utility used to wait for a function to return a certain expected condition.

Some possible uses cases include:

  • Wait for API response to return with code 200
  • Wait for a file to exist (or not exist)
  • Wait for a thread lock on a resource to expire

Polling2 is handy for getting rid of all that duplicated polling-code. Often, applications require retrying until the correct response is returned. Why re-implement the ability to poll again and again? Use Polling2!

Polling2 is a fork of the original polling. It was forked when the original maintainer failed to respond to issues or PRs.

Polling2 is under active development. Would you like to see a particular feature? Ask and thou shall recieve.

Installation

pip install polling2

Development installation

# install lib, but use system links from the repo into sitepackages.
python setup.py develop
# install test dependenices.
python setup.py test
# run the tests
pytest tests

Example:

# This call will wait until the file exists, checking every 0.1 seconds and stopping after 3 seconds have elapsed
file_handle = polling2.poll(
    lambda: open('/tmp/myfile.txt'),
    ignore_exceptions=(IOError,),
    timeout=3,
    step=0.1)

# Polling will return the value of your polling function, so you can now interact with it
file_handle.close()

There are more examples in the documentation.

API and user guide at Read the Docs

Read the Docs

Project details


Download files

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

Source Distribution

polling2-0.4.7.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polling2-0.4.7-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file polling2-0.4.7.tar.gz.

File metadata

  • Download URL: polling2-0.4.7.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1

File hashes

Hashes for polling2-0.4.7.tar.gz
Algorithm Hash digest
SHA256 d84ecf4f90da94dfe932bf676524ff4990cf8bddaeb80ec918b9419e1548f155
MD5 2fa739610dd9da0187cc064d8e6f92e8
BLAKE2b-256 0590b8e77dc492689d7e59893777b954ab27a4af0dbb7eef33dc03b675ae96ce

See more details on using hashes here.

File details

Details for the file polling2-0.4.7-py2.py3-none-any.whl.

File metadata

  • Download URL: polling2-0.4.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1

File hashes

Hashes for polling2-0.4.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b36d9ae09da0e916c6e7c63378fabf4c8259d59735981bb9264b5285bc6fc80f
MD5 ee2d8fdb8b6f16c6e92b754af2d00457
BLAKE2b-256 32ebf37fad5079e05c00864fd21f9f1ea56087a47b59cfec1a08d7714213633d

See more details on using hashes here.

Supported by

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