Asyncio HTTP library with thread-safe connection pooling, file post, and more.
Project description
What is this about?
Yieldfrom is a project to port various useful Python 3 libraries, both standard library and otherwise, to work under Asyncio. The intention is to have the port be as alike as possible to the original, so that the learning curve is minimal, and to make porting dependent modules as easy as possible.
This package is a port of the Urllib3 package.
Some functions, methods, and properties have become coroutines. This document itemizes those, with a few notes on how usage needs to be different. Other than what is mentioned here, the classes, methods and functions are all named the same and used the same.
Since the ‘yield from coroutine’ statements block the current method until the statement completes, this variant can be a statement-for-statement replacement for the original, and the architecture of the app is unchanged. No callbacks anywhere.
imports
Instead of importing like:
from urllib.connections import HTTPConnection from urllib import connections
- use:
from yieldfrom.urllib.connections import HTTPConnection from yieldfrom.urllib import connections
Classes HTTPConnection and HTTPSConnection
The connect method is now a coroutine. Call it with yield from, like ‘c = yield from conn.connect(…)’, and otherwise the argument list is the same.
Classes HTTPConnectionPool, PoolManager, and ProxyManager
These classes all feature methods urlopen, request, request_encode_url, and request_encode_body , which have become coroutines. The argument list is unchanged, and the functionality is unchanged. Just call it with ‘yield from’ as a coroutine.
Class HTTPResponse
There is one new method, init() which is a coroutine. Its function was performed by the constructor in Urllib3, but needs to be async here. A coroutine constructor would be difficult, so the async portions are moved to the init() method. Run it as a coroutine after constructing an HTTPResponse. Generally, users of the module won’t be creating HTTPResponses directly, so this should not be much of an issue.
The read, readinto, stream methods are all coroutines. The data attribute is actually a property, now a coroutine, and should be referenced with the yield from syntax, like ‘d = yield from resp.data’.
The from_httplib classmethod is a coroutine also, though you probably won’t be using it directly.
The stream method does not actually stream, but preloads the body and simulates a stream for compatibility with modules and apps that use the method.
Otherwise
Other than the changes above, the API is the same as the original, and excellent documentation can be found at: URLLIB3 <http://urllib3.readthedocs.org>.
Changes
2014-12-29
version 0.1.2
Removed bug that caused false alarms on ‘unverified connection’ Fixed test imports to unambiguosly import yieldfrom modules bug fixes in tests.
2014-10-10
version 0.1.1
Converted to Asyncio
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file yieldfrom.urllib3-0.1.4.zip
.
File metadata
- Download URL: yieldfrom.urllib3-0.1.4.zip
- Upload date:
- Size: 66.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 759f2ead636bfdeddabd0b440cd6396791977b27e6f3de44c15a81ee7da8bd63 |
|
MD5 | c10def63a4d5df2572b258598f27948a |
|
BLAKE2b-256 | 401c3417ef77d7b045441e7105dd2e344102a73c025fae1f2ddd8c0926ab982c |