Yury Selivanov <yseliva...@gmail.com> added the comment:

Thanks for posting this, Mike.

> Vague claims of "framework X is faster because it's async" appear, impossible 
> to confirm as it is unknown how much of their performance gains come from the 
> "async" aspect and how much of it is that they happened to rewrite a new 
> framework from scratch in a completely different way (hint: it's the latter).

These kind of claims are not specific to async vs. sync. They are all over the 
place for every two pieces of comparable technologies. While novice users might 
base their technology choice purely on such benchmarks, it's less of an issue 
for startups/tech companies.

That said, I agree with most of your points so far.

> The asyncpg project, one of the few asyncio database drivers that exists, 
> notes in its FAQ "asyncpg uses asynchronous execution model and API, which is 
> fundamentally incompatible with SQLAlchemy" [2], yet we know this is not true 
>  because SQLAlchemy works just fine with gevent and eventlet, with no 
> architectural changes at all.

But it is true. Making asynchronous network requests in asyncio requires 
async/await or using callbacks and it's not possible to do them, say, from 
__getattr__ (you mention this yourself).  This is what that particular comment 
is about, nothing more. Using gevent and eventlet as examples in this 
particular context isn't helping you. Apologies for nitpicking, I know it's not 
the point of this discussion.

> A day later, someone took the same idea and got Flask to work in an asyncio 
> event loop at [5].  The general idea of using greenlet in this way is also 
> present at [6], so I won't be patenting this idea today as oremanj can claim 
> prior art.

Yes, this approach definitely works and I even did that in production myself a 
few years ago with https://github.com/1st1/greenio (it's terribly outdated now).

> The recipe is simple and so far appears to be very effective.

This recipe was one of the reasons why I added `loop.set_task_factory` method 
to the spec, so that it's possible to implement this in an *existing* event 
loop like uvloop. But ultimately asyncio is flexible enough to let users use 
their own event loop which can be compatible with greenlets among other 
improvements.

Ultimately, asyncio will probably never ship with greenlets integration enabled 
by default, but we should definitely make it possible (if there are some 
limitations now).  It doesn't seem to me that nested event loops are needed for 
this, right?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue22239>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to