
Show HN: Asynchronous HTTP/2 client for Python 2.7 - vsmhn
https://github.com/vladmunteanu/th2c
======
ericfrederich
Qt has an event loop and async http library. I've used it from PyQt with great
success.

~~~
vsmhn
Does it support HTTP/2?

~~~
jcelerier
yep, apparently
([https://bugreports.qt.io/browse/QTBUG-50936](https://bugreports.qt.io/browse/QTBUG-50936))

------
vsmhn
Why Python 2 and not Python 3?

Short answer is: because Python 3 already benefits from a better, more
complete client: aioh2
([https://github.com/decentfox/aioh2](https://github.com/decentfox/aioh2))
that works with Python's asyncio.

th2c is mostly intended for Tornado backends, trying to keep a similar
interface and compatibility with Request / Response objects.

It was initially developed in order to be able to communicate with APNS from a
python 2.7 environment.

~~~
ericfrederich
How does that compare to aiohttp? What are the benefits?

~~~
omginternets
aio isn't available for py2. The benefit is that this is available for py2.

~~~
loeg
There is
[https://github.com/vstinner/trollius](https://github.com/vstinner/trollius)
for vanilla Python2.

~~~
vsmhn
trollius is no longer maintained

~~~
loeg
It's still a reasonable starting place for anyone wanting asyncio on vanilla
Python2. Outside of vanilla Python2, Tauthon also has some tracking issues for
the language extensions and libraries needed for a backport of asyncio to
Tauthon.[0]

[0]:
[https://github.com/naftaliharris/tauthon/issues/10](https://github.com/naftaliharris/tauthon/issues/10)

------
gigatexal
I’m of the opinion that one should only maintain python2 projects not actively
develop and expand them. If your project needed http2 then it should be ported
to python3.

Edit: would using python3 in a container make sense where the distribution
only ships legacy python?

~~~
harryf
The current version of Redhat - RHEL 7 - which most banks, large enterprises
etc. are using comes with a system python version of 2.7.5 and you need to
jump through hoops to install Python 3.x ( e.g.
[https://stackoverflow.com/questions/8087184/problems-
install...](https://stackoverflow.com/questions/8087184/problems-installing-
python3-on-rhel) ), which may not even be possible if you're in an environment
where security is tightly controlled.

There is the possibility of Python 3.x being default in RHEL 8 (
[https://fedoraproject.org/wiki/Changes/Python_3_as_Default](https://fedoraproject.org/wiki/Changes/Python_3_as_Default)
) but right now RHEL 8 isn't released and there's no date for it being
released. And even once it is released, it will be more years before big
enterprises really start switching

TLDR ignore python 2.7 and alienate RHEL customers

~~~
Spiritus
>you need to jump through hoops to install Python 3.x

What? You can install Python 3.6 from EPEL[1], takes 5 seconds.

[1] [https://fedoraproject.org/wiki/EPEL](https://fedoraproject.org/wiki/EPEL)

~~~
rckclmbr
Then you have to use scl, which kind of sucks. Better to just install the
fedora packages. Or compile it yourself (but you should really package it if
you're deploying it on a lot of servers)

------
yoz-y
Any specific reason to develop this for Python 2 rather than Python 3?

~~~
meddlepal
There's still a lot of existing and new Python 2 code being written.
Idealistically we would all be on Python 3, but software is a messy land.

~~~
goatlover
It's been ten years, so it's gone beyond "idealistically".

~~~
CJefferson
Still not distributed by default on Mac or Ubuntu long term release, unlike 2.

~~~
rspeer
The current Ubuntu long-term support release is Xenial, which comes with
_only_ Python 3 installed. If you're talking about Trusty, its support is
ending fairly soon.

On Xenial, you have to separately install an optional package for Python 2.
When you try to run /usr/bin/python on a fresh Xenial install, it'll tell you
that you need to install a package such as python-minimal==2.7.11, whereas
/usr/bin/python3 is already there.

~~~
CJefferson
Woops, my LTS is obviously out of date. Thanks.

------
benatkin
Its name made me think of THC.

I'll ask the obvious question: why not Python 3?

~~~
vsmhn
Well, Python 3 already has a similar library that deals with this stuff, such
as [https://github.com/decentfox/aioh2](https://github.com/decentfox/aioh2).

Also, this is mostly intended for Tornado backends, offering compatibility
with Tornado's request / response objects.

~~~
peterkelly
Are people really still so closely wedded to Python 2 that they find it easier
to reimplement all the features they need from Python 3 in the former, instead
of switching to the latter?

~~~
siimtalvik
yes.

I had a coworker who was against moving to python3(and kept on writing python2
code for a while) because you need to use brackets with python3 print
statement.

