Skip to main content

High resoltion timer for asyncio

Project description

AsyncIO compatible periodic timer. Linux only and very alpha API.

Example

The timer is implemented as a straightforward protocol similar to how the asyncio’s network protocols are handled:

class MyTimer(aiotimer.Protocol):
    def __init__(self):
        self.counter = 0

    def timer_started(self, timer):
        self.timer = timer

    def timer_ticked(self):
        # Callback triggered when the timer interval elapses
        ...

    def timer_overrun(self):
        # Callback triggered if the timer_ticked callback runtime
        # should exceed the timer interval. Return True to
        # reschedule, otherwise the timer is aborted.
        return True

    def error_received():
        ...

The protocol can then be used to create a new timer:

# Schedule once every 10th of a second
aiotimer.create_timer(MyTimer, 0.1, loop=loop)

Project details


Release history Release notifications

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
aiotimer-0.1.0.tar.gz (34.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page