Skip to main content

pending time-delayed events scheduling

Project description

Pending events awaitable for asyncio

Instantiate a Pending awaitable, register events scheduled to be returned after a given number of seconds, and then await.

Once the first one (with smallest scheduling delay) is returned, re-await to get the next one, and so on. Optionally cancel or postpone (reschedule) scheduled events.

Example of use:

>>> import asyncio
>>> from pending import Pending
>>> events = Pending()
>>> events.schedule("second", 10)
>>> events.schedule("first", 9)
>>> async def main():
...    for i in len(events):
...       evt = await events
...       print(evt)
...
>>> asyncio.run(main())
first
second

Note: the registered "event" can be any hashable object.

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

pending-1.3.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

pending-1.3-py3-none-any.whl (9.8 kB view hashes)

Uploaded Python 3

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