Skip to content
This repository has been archived by the owner on Oct 5, 2020. It is now read-only.

add more taskcluster.async documentation #83

Merged
merged 3 commits into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ but unnamed temporary credentials can be created regardless of your scopes.## AP
The REST API methods are documented on
[http://docs.taskcluster.net/](http://docs.taskcluster.net/)

## Sync vs Async

The objects under `taskcluster` (e.g., `taskcluster.Queue`) are python2-compatible and operate synchronously. This allows for taskcluster api access, though for bulk operations will be considerably slower... more than 10x slower in cases where you need to run many api calls that would benefit from concurrency.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than the sync api is slower inherently, it's more the case that the async api can easily run with concurrency. As it's written, it almost sounds like a single sync call is up to 10x slower than a single async call. Let's frame it more like "This allows for making concurrent API calls, which can considerably improve performance for applicable workloads"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true it's just as fast on a single sync call. However, anyone using taskcluster-client.py against even medium-sized graphs should see speedups using async. But agreed, I can reword and make it a positive statement for async rather than a negative for sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


The objects under `taskcluster.async` (e.g., `taskcluster.async.Queue`) require `python>=3.5`. `taskcluster.async` will only be available under the python3 wheel or the source distribution; the python2 wheel will not include it. The async objects use asyncio coroutines for concurrency; this allows us to put I/O operations in the background, so operations that require the cpu can happen sooner. The code would look something like
Copy link
Contributor

@edmorley edmorley Aug 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "taskcluster.async will only be available under the python3 wheel or the source distribution; the python2 wheel will not include it" bit is now no longer the case, since it was going to be a bit of a hack in #82.


```python
import asyncio
from taskcluster.async import Auth

async def do_ping():
a = Auth()
print(await a.ping())

loop = asyncio.get_event_loop()
loop.run_until_complete(do_ping())
```

Other async code examples are available [here](#methods-contained-in-the-client-library).

Here's a slide deck for an [introduction to async python](https://gitpitch.com/escapewindow/slides-sf-2017/async-python).

## Usage

* Here's a simple command:
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def run_tests(self):
tests_require=tests_require,
cmdclass={'test': Tox},
zip_safe=False,
classifiers=['Programming Language :: Python :: 2',
'Programming Language :: Python :: 3'],
classifiers=['Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'],
)