Skip to main content

Thread-based, JS-like asynchronous calls for Python.

Project description


.. image:: :target:

Thread-based, JS-like asynchronous calls for Python. Works in both
Python 2.7 and Python 3.5+.


Release version:

.. code:: bash
pip install call

Development version

.. code:: bash

git clone
cd call
# Activate virtualenv if needed
python install

The library requires no other dependencies, and (will soon) support
Python's ``await`` keyword.


Create a call:

.. code:: python

def cb(resolve, reject):
result = factorial(100)

call = Call(cb)

Wrap a synchronous function in a Call:

.. code:: python
call = Call.from_function(factorial, 10)

Chain calls with the ``then`` keyword

.. code:: python

call = Call(cb).then(lambda val: print(val))

Catch errors:

.. code:: python

call = Call(cb)\
.then(lambda val: raise Exception())\
.catch(lambda err: print('Whoops'))

Compose calls:

.. code:: python

results = Call.all([Call(cb) for _ in range(10)])

Block thread until resolved (or raises on failure):

.. code:: python

result = call.wait()

Wait for call to either resolve or reject. Note that it is not recommended to get the data directly, as it may be
``None``, which may or may not indicate that an error has occurred.

.. code:: python

result = # Not recommended


The repository follows the ``git flow`` standards. Create a feature branch, then ask for a pull/merge request.

The main repository is on GitLab, however the GitHub mirror is functional and you should be able to ask for pull
requests. However, they will be processed in GitLab.

Project details

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

async_call-0.1.2-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

async_call-0.1.2-py2-none-any.whl (3.8 kB view hashes)

Uploaded Python 2

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