Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Result and friends: callable objects which will receive a value at a later point in time.

Project Description

An Asynchron is the base class for several callable subclasses which will receive values at a later point in time, and can also be used standalone without subclassing.

A call to an Asynchron will block until the value is received or the Asynchron is cancelled, which will raise an exception in the caller. An Asynchron may be called by multiple users, before or after the value has been delivered; if the value has been delivered the caller returns with it immediately. An Asynchron’s state may be inspected (pending, running, ready, cancelled). Callbacks can be registered via an Asychron’s .notify method.

An incomplete Asynchron can be told to call a function to compute its value; the function return will be stored as the value unless the function raises an exception, in which case the exception information is recorded instead. If an exception occurred, it will be reraised for any caller of the Asynchron.

Trite example:

A = Asynchron(name="my demo")

Thread 1:
  value = A()
  # blocks...
  # prints 3 once Thread 2 (below) assigns to it

Thread 2:
  A.result = 3

Thread 3:
  value = A()
  # returns immediately with 3

You can also collect multiple Asynchrons in completion order using the report() function:

As = [ ... list of Asynchrons or whatever type ... ]
for A in report(As):
  x = A()     # collect result, will return immediately
  print(x)    # print result
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cs.asynchron-20160828.tar.gz (5.0 kB) Copy SHA256 Checksum SHA256 Source Aug 28, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting