[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Benefits of asyncio

On 03/06/14 14:57, Chris Angelico wrote:
> On Tue, Jun 3, 2014 at 9:05 PM, Burak Arslan <burak.arslan at arskom.com.tr> wrote:
>> On 06/03/14 12:30, Chris Angelico wrote:
>>> Write me a purely nonblocking
>>> web site concept that can handle a million concurrent connections,
>>> where each one requires one query against the database, and one in a
>>> hundred of them require five queries which happen atomically.
>> I don't see why that can't be done. Twisted has everyting I can think of
>> except database bits (adb runs on threads), and I got txpostgres[1]
>> running in production, it seems quite robust so far. what else are we
>> missing?
>> [1]: https://pypi.python.org/pypi/txpostgres
> I never said it can't be done. My objection was to Marko's reiterated
> statement that asynchronous coding is somehow massively cleaner than
> threading; my argument is that threading is often significantly
> cleaner than async, and that at worst, they're about the same (because
> they're dealing with exactly the same problems).

Ah ok. Well, a couple of years of writing async code, my 
not-so-objective opinion about it is that it forces you to split your 
code into functions, just like Python forces you to indent your code 
properly. This in turn generally helps the quality of the codebase.

If you manage to keep yourself out of the closure hell by not writing 
more and more functions inside one another, I say async code and 
(non-sloppy) blocking code looks almost the same. (which means, I guess, 
that we mostly agree :))