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


Download files

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

Source Distribution

aiotimer-0.1.0.tar.gz (34.6 kB view details)

Uploaded Source

File details

Details for the file aiotimer-0.1.0.tar.gz.

File metadata

  • Download URL: aiotimer-0.1.0.tar.gz
  • Upload date:
  • Size: 34.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiotimer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd239e161792cbfd1f1fc9d7f206a42b90b588ab9592c09dc6e877c5d3f29b19
MD5 13be3aa8c460d1e4fdff97982108c7a1
BLAKE2b-256 5a4251f4afa9ea19ad41606b2f20ef21cc3a6d6bee18febe16034aaea2570388

See more details on using hashes here.

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