Call
====
.. image:: https://api.codacy.com/project/badge/Grade/91959f98ff34469884415e96ba2ff763 :target: https://www.codacy.com/app/solarliner/call?utm_source=gitlab.com&utm_medium=referral&utm_content=solarliner/call&utm_campaign=Badge_Grade
Thread-based, JS-like asynchronous calls for Python. Works in both
Python 2.7 and Python 3.5+.
Install
-------
Release version:
.. code:: bash
pip install call
Development version
.. code:: bash
git clone https://gitlab.com/solarliner/call.git
cd call
# Activate virtualenv if needed
python setup.py install
The library requires no other dependencies, and (will soon) support
Python's ``await`` keyword.
Use
---
Create a call:
.. code:: python
def cb(resolve, reject):
result = factorial(100)
resolve(result)
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
call.join()
result = call.data # Not recommended
Contribute
----------
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.
====
.. image:: https://api.codacy.com/project/badge/Grade/91959f98ff34469884415e96ba2ff763 :target: https://www.codacy.com/app/solarliner/call?utm_source=gitlab.com&utm_medium=referral&utm_content=solarliner/call&utm_campaign=Badge_Grade
Thread-based, JS-like asynchronous calls for Python. Works in both
Python 2.7 and Python 3.5+.
Install
-------
Release version:
.. code:: bash
pip install call
Development version
.. code:: bash
git clone https://gitlab.com/solarliner/call.git
cd call
# Activate virtualenv if needed
python setup.py install
The library requires no other dependencies, and (will soon) support
Python's ``await`` keyword.
Use
---
Create a call:
.. code:: python
def cb(resolve, reject):
result = factorial(100)
resolve(result)
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
call.join()
result = call.data # Not recommended
Contribute
----------
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.
Metadata
Release files for async-call 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_call-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
| async_call-0.1.2-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 7.6 kB
Release files / async_call-0.1.2-py3-none-any.whl
| Download URL | async_call-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f85e69e0b3052240e9156376a33a18c8736522c1a5118d5434302b48fa9cd87
|
|
BLAKE2b-256 checksum How to use checksums |
4fef9b273f084a36e8e4fef938cf7af41293dca4c8e56e912cbeb678c90a953d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
|
Release files / async_call-0.1.2-py2-none-any.whl
| Download URL | async_call-0.1.2-py2-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
19dde8d0d787609e285cd483343da04f120d919699746c966bb6708472f2ac59
|
|
BLAKE2b-256 checksum How to use checksums |
8656aa1fbd0af24fd22c250a283d8436619169b9b5e66b0cf12d00ff4b839344
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
|