Asynchonous API

Pulsar asynchronous api is built on top of the new python asyncio module.

Async object interface

This small class is the default interface for asynchronous objects. It is provided mainly for documentation purposes.

class pulsar.async.futures.AsyncObject[source]

Interface for async objects


The event loop associated with this object


Optional logger instance, used by the logger attribute


True when in debug mode


The logger for this object.

It is either the _logger or the logger of the _loop

timeit(method, times, *args, **kwargs)[source]

Useful utility for benchmarking an asynchronous method.

  • method – the name of the method to execute
  • times – number of times to execute the method
  • args – positional arguments to pass to the method
  • kwargs – key-valued arguments to pass to the method

a Future which results in a Bench object if successful

The usage is simple:

>>> b = self.timeit('asyncmethod', 100)
class pulsar.async.futures.Bench(times, loop=None)[source]

Execute a given number of asynchronous requests and wait for results.


The total time taken for execution


class pulsar.async.lock.LockBase(name, *, loop=None, timeout=None, blocking=True)[source]

A asynchronous locking primitive associated to a given name.

An asynchronous lock is in one of two states, ‘locked’ or ‘unlocked’. It is created in the unlocked state. It has two basic methods, acquire() and release. When the state is unlocked, :meth:().acquire` changes the state to locked and returns immediately.

When the state is locked, acquire() wait until a call to release() changes it to unlocked, then the acquire() call resets it to locked and returns.


The time to wait for the lock to be free when acquiring it. When False it does not block, when True it blocks forever, when a positive number blocks for blocking seconds.


Free the lock after timeout seconds. If timeout is None (default) does not free the lock until release is called.


Try to acquire the lock


Return True if the lock is aquired


Release the lock

class pulsar.async.lock.Lock(name, *, loop=None, timeout=None, blocking=True)[source]

An asynchronous lock

Async Utilities

A collection of asynchronous utilities which facilitates manipulation and interaction with asynchronous components.


Maybe Async

Chain Future

Multi Async

Async While

Run in loop