M
M
MOV_UA2020-07-19 12:21:42
Python
MOV_UA, 2020-07-19 12:21:42

How can you write an asynchronous function differently?

#  Почему вот так работает
async def loadpg(url_):
    return session.get(url_, timeout=30)
obj = await loadpg(url_=link)

#  А вот так нет
obj = await session.get(link, timeout=30)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2020-07-19
@bacon

Judging by the first example, session.get is synchronous. And still it is necessary to tell that whence undertook and to result the text of an error.

A
Andrey_Dolg, 2020-07-19
@Andrey_Dolg

Without the rest of the code, the performance of the examples is in question. )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question