New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async and await #2801

Closed
screendriver opened this Issue Oct 3, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@screendriver

Python 3.5 introduced coroutines with async and await syntax. Specification about that can be read in PEP 492.

Are there any plans to support this? Because of network lags or slow connections it would make sense to make asynchronous http requests.

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Oct 3, 2015

Member

@screendriver At the current time there are no plans to support async and await. This is not because they aren't a good idea: they are. It's because to use them requires quite substantial code changes.

Right now requests is a purely synchronous library that, at the bottom of its stack, uses httplib to send and receive data. We cannot move to an async model unless we replace httplib. The best we could do is provide a shorthand to run a request in a thread, but asyncio already has just such a shorthand, so I don't believe it would be valuable.

Right now I am quietly looking at whether we can rewrite requests to work just as well in a synchronous environment as in an async one. However, the reality is that doing so will be a lot of work, involving rewriting a lot of our stack, and may not happen for many years, if ever.

Member

Lukasa commented Oct 3, 2015

@screendriver At the current time there are no plans to support async and await. This is not because they aren't a good idea: they are. It's because to use them requires quite substantial code changes.

Right now requests is a purely synchronous library that, at the bottom of its stack, uses httplib to send and receive data. We cannot move to an async model unless we replace httplib. The best we could do is provide a shorthand to run a request in a thread, but asyncio already has just such a shorthand, so I don't believe it would be valuable.

Right now I am quietly looking at whether we can rewrite requests to work just as well in a synchronous environment as in an async one. However, the reality is that doing so will be a lot of work, involving rewriting a lot of our stack, and may not happen for many years, if ever.

@Lukasa Lukasa closed this Oct 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment