Skip to main content

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.


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.

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’.

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 <>.



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.


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 (66.1 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page