Skip to content
Back to top
View this page

# pyrate_limiter.clocks module

Clock implementation using different backend

class pyrate_limiter.clocks.AbstractClock

  Bases: `ABC`

  Clock that return timestamp for now

  abstractmethod now()

    Get time as of now, in milliseconds

    Return type:

      `int` | `Awaitable`[`int`]

class pyrate_limiter.clocks.MonotonicAsyncClock

  Bases: `AbstractClock`

  Monotonic Async Clock, meant for testing only

  async now()

    Get monotonic time in milliseconds

    Return type:

      `int`

class pyrate_limiter.clocks.MonotonicClock

  Bases: `AbstractClock`

  now()

    Get monotonic time in milliseconds

    Return type:

      `int`

class pyrate_limiter.clocks.PostgresClock(pool)

  Bases: `AbstractClock`

  Get timestamp using Postgres as remote clock backend

  now()

    Get current time in milliseconds using Postgres.

    Falls back to local time if the DB query fails for any reason.

    Return type:

      `int`