[Async-sig] Warts both in asyncio way and greenlet-based approach

Andrew Svetlov andrew.svetlov at gmail.com
Tue Aug 2 14:39:11 EDT 2016


Long story short: in async world every IO library should use asyncio.
Unfortunately for the most  popular libraries (requests, django, flask,
sqlalchemy etc.) it's impossible to rewrite the code keeping backward
compatibility. Much easier to create a new library than rewrite existing
one.

Regarding to gevent -- please read excellent Glyph's article 'Unyielding':
https://glyph.twistedmatrix.com/2014/02/unyielding.html

It covers pretty well why explicit yield points are better than implicit
ones.

Shortly explicit `await`'s give you 'atomic consistency' but using gevent
you should expect context switch in every opcode instruction.

It's much easier to test cover code with several (ok, many) context switch
points. But test covering the code which may switch on every line and
several times in the same line is practically impossible.

Also my 2 cents. We used gevent. Even in very tiny application (command
line client to upload huge files over HTTP, about 1k lines of code) under
high load we got reports about gevent hub crashes.

Even gevent core (hub is something like asyncio loop) is not 100% stable.
Unfortunately we was not able to reproduce the problem by our test suite --
it requires really high load and occurs very rare.

Well, the most gevent users can live with that -- gunicorn just restarts
dead worker and that's it.

But it is the sign for the problem: gevent crashes are extremely hard to
debug.

P.S.
You might keep my writings about gevent as my private opinion, and it is.
But from my perspective asyncio based solutions have much more predictable
behavior and much more friendly to debug-and-fix problems.
-- 
Thanks,
Andrew Svetlov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/async-sig/attachments/20160802/9b124565/attachment.html>


More information about the Async-sig mailing list