This repository has been archived by the owner on Oct 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
add more taskcluster.async documentation #83
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
```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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.