Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time

requests-threads 🎭

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

It's awesome, basically β€”Β check it out:


Let's send 100 concurrent requests! \o/

Example Usage using async/await β€”

from requests_threads import AsyncSession

session = AsyncSession(n=100)

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

if __name__ == '__main__':

This example works on Python 3 only. You can also provide your own asyncio event loop!

Example Usage using Twisted β€”

from twisted.internet.defer import inlineCallbacks
from twisted.internet.task import react
from requests_threads import AsyncSession

session = AsyncSession(n=100)

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

    for response in responses:
        r = yield response

if __name__ == '__main__':

This example works on both Python 2 and Python 3.

Each request is sent via a new thread, automatically. This works fine for basic use cases. This automatically uses Twisted's asyncioreactor, if you do not provide your own reactor (progress to be made there, help requested!).

This is a an experiment, and a preview of the true asynchronous API we have planned 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


This codebase was inspired by future work on Requests, as well as requests-twisted.