(original) (raw)



On Thu, Apr 23, 2015 at 5:32 PM, Yury Selivanov <yselivanov.ml@gmail.com> wrote:
Hi Wolfgang,

On 2015-04-23 8:27 AM, Wolfgang Langner wrote:
On Thu, Apr 23, 2015 at 12:35 PM, Paul Sokolovsky <pmiscml@gmail.com> wrote:

Hello,

On Thu, 23 Apr 2015 12🔞51 +0300
Andrew Svetlov <andrew.svetlov@gmail.com> wrote:

\[\]

3.
async with and async for
Bead idea, we clutter the language even more and it is one more
thing every newbie could do wrong.
for x in y:
result = await f()
is enough, every 'async' framework lived without it over years.
async for i in iterable:
pass

is not equal for

for fut in iterable:
i = yield from fut
But people who used Twisted all their life don't know that! They just
know that "async for" is not needed and bad.


I don't think it is bad nor not needed, but the syntax is not beautiful and
for the 90% not doing async stuff irritating and one more thing to learn
and do right/wrong.
There is no way to do things wrong in PEP 492\. An object
either has \_\_aiter\_\_ or it will be rejected by async for.
An object either has \_\_aenter\_\_ or it will be rejected by
async with.

Don't mean it can be done wrong on execution or syntax level.
I mean for a beginner it is not as easy an more and some will try
async in some places, yes they will get an error. But there is a
new possibility to get such errors if async is there for with and for statements.
And the next beginner will then implement \_\_aiter\_\_ instead of \_\_iter\_\_ because
he/she don't get it.

On the other side I like "await" and \_\_await\_\_ implementation.
Symmetric good easy to explain, same with "int" and "\_\_int\_\_" and all others.

transaction = yield from connection.transaction()
try:
...
except:
yield from transaction.rollback()
else:
yield from transaction.commit()

is certainly more irritating than

async with connection.transcation():
...


Sorry till now I use async stuff and database access and do it in an extra thread in sync mode.
No performance problems and can use all good maintained database libraries.
Also twisteds RDBMS (adbapi) is enough here. First I thought it is not enough or to slow but this was not the case.
https://twistedmatrix.com/documents/current/core/howto/rdbms.html

Here I am on line with Mike Bayer:
http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/