Skip to main content

A Requests session that returns awaitable Twisted Deferreds instead of response objects.

Project description

This repo contains a Requests session that returns awaitable Twisted Deferreds instead of Response objects.

It’s awesome, basically — check it out:


Example Usage (using async/await):

from requests_threads import AsyncSession

session = AsyncSession()

async def _main():
    rs = []
    for _ in range(100):
        rs.append(await session.get(''))

if __name__ == '__main__':

This example works on Python 3 only.

Example Usage (using Twisted):

from twisted.internet.defer import inlineCallbacks
from twisted.internet.task import react
import requests

session = requests.AsyncSession()

def main(reactor):
    responses = []
    for i in range(100):

    for response in responses:
        r = yield response

if __name__ == '__main__':

This example works on Python 2 and Python 3.

Each request is sent via a new thread, automatically. This works fine for basic use cases.

This is a an experiment, and a preview of the true asyncronous API we have panned for Requests that is currently in the works, but requires a lot of development time. If you’d like to help (p.s. we need help, send me an email).

This API is likely to change, over time, slightly.


$ pipenv install requests-threads

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests_threads-0.1.0.tar.gz (3.5 kB view hashes)

Uploaded source

Built Distribution

requests_threads-0.1.0-py2.py3-none-any.whl (4.6 kB view hashes)

Uploaded py2 py3

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