
Ask HN: Starting a new Python project with async networking - defen
Surveying the async networking landscape for Python has me a bit overwhelmed. There&#x27;s raw async&#x2F;await in 3.5+, curio, asyncio, gevent, tornado, stackless, and probably others. If you were starting a new project today, without concern for backward compatibility, what would you use? Python 2.x or 3.x solutions please; I know about Erlang&#x2F;Go&#x2F;Node but they aren&#x27;t a good fit for this project.
======
itamarst
1\. Python 2 is EOL in 2020, don't use it for new projects.

2\. async/await it just an API layer on top of a framework. Thus there is no
such thing as raw async/await, it has to be used with a framework of some sort
(e.g. Python's built-in asyncio).

3\. gevent patches the socket library. Terrible idea. Don't use it.

4\. What protocols do you need? Twisted probably has the most implemented, but
asyncio and tornado have a bunch too, and not always the same ones.

~~~
defen
Thanks.

Protocols - HTTP + some custom stuff on top of TCP.

~~~
itamarst
I'd personally use Twisted, but I'm biased insofar as I helped develop it. It
has both equivalent of Javascript promises (called Deferreds) and ability to
interact with them using async/await if you like that idiom more
([http://twistedmatrix.com/documents/current/core/howto/defer-...](http://twistedmatrix.com/documents/current/core/howto/defer-
intro.html#coroutines-with-async-await)).

But that's just me.

Given limited protocol needs, I suggest skimming docs for asyncio, Twisted,
and Tornado and seeing which seems to make the most sense to you. For Twisted
HTTP client and server to look at are Treq
([https://treq.readthedocs.io/en/release-17.8.0/](https://treq.readthedocs.io/en/release-17.8.0/))
and Klein
([https://klein.readthedocs.io/en/latest/](https://klein.readthedocs.io/en/latest/)).

------
eesmith
I would use curio to experiment with the concepts because it, unlike the
others, isn't based on event-loops, callbacks, futures, etc. This makes it
easier to understand what async can become.

Then I would likely switch to gevent or tornado, because more people are
involved in those projects.

~~~
itamarst
There's an event loop underneath, even if it's not directly exposed.

~~~
eesmith
Isn't based on exposing an event loop, etc. API to the user.

