Asyncio HTTP library with thread-safe connection pooling, file post, and more.
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.
Instead of importing like:
from urllib.connections import HTTPConnection from urllib import connections
- 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.
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.
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>.
Removed bug that caused false alarms on ‘unverified connection’ Fixed test imports to unambiguosly import yieldfrom modules bug fixes in tests.
Converted to Asyncio
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size yieldfrom.urllib3-0.1.4.zip (66.1 kB)||File type Source||Python version None||Upload date||Hashes View|