10

I would like to use python-requests in my server to send PUSH notification to Apple push server, my questions:

  1. Does python-requests support asynchronous calls ?
  2. Does python-request support HTTP2 ?

Thanks

Thomas Young
  • 186
  • 1
  • 2
  • 10

2 Answers2

9

As recommended by @qris in this comment, you should consider using HTTPX (https://github.com/encode/httpx/) .

It's in beta, but a 1.0 release is planned.

It supports both async as well as HTTP/2 and provides a requests-compatible API.

Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
Greg Dubicki
  • 5,983
  • 3
  • 55
  • 68
1

It doesn't support HTTP/2 now (Release v2.18.1). As in the doc (http://docs.python-requests.org/en/master/):

Requests allows you to send organic, grass-fed HTTP/1.1 requests, without the need for manual labor.

But you can try Hyper if you need to send HTTP/2 requests: https://hyper.readthedocs.io/en/latest/.

hyper supports Python 3.4 and Python 2.7.9, and can speak HTTP/2 and HTTP/1.1.

Huang
  • 599
  • 2
  • 6
  • 10
    Given that Hyper is alpha software and hasn't had a release in 4 years, you may be better off with [HTTPX](https://www.python-httpx.org/). It's in beta, and planning a stable release very soon (April 2020). – qris Apr 01 '20 at 11:15
  • hyper is [no longer maintained](https://github.com/python-hyper/hyper#hyper-http2-client-for-python) – Boris Verkhovskiy Mar 13 '22 at 17:37
  • requests doesn't [_and will not_](https://github.com/psf/requests/issues/5757#issuecomment-782695134) support HTTP/2 – nikhilweee Jan 22 '23 at 18:08