What problems can occur with aiohttp?

Still it is an asynchronous aiohttp framework, however, the typical incidents async to catch failed.
By this I do not really understand how it works?
Let's say I want to calculate the variable b, which is just on the backend is equivalent to the variable a, which in turn goes to the database.

The way this will happen: there coroutine in which the assignment of b=a by running a different subroutine that performs the query to the database - go there for a variable.

These tasks are divided in the event loop get a different. and on the first routine, which climbs to the base. Obviously it will take longer than a simple assignment b=a, so the event loop will go straight to the assignment. So the treatment is not similar to synchronous. How does it work? Everywhere write that aiohttp allows you to run asynchronous worker and write code like it's synchronous.

I can rely on this statement?
There should be some reservations? To improve performance it is better to write corrucini small and tasks are broken up into a bunch of subroutines? or, on the contrary, it is better to push in one coroutine?

Sorry, I'm just a little confused
June 3rd 19 at 19:29
1 answer
June 3rd 19 at 19:31
Everywhere write that aiohttp allows you to run asynchronous worker and write code like it's synchronous.

Garbage you write.

therefore, the event loop will go straight to the assignment.

No, the whole chain of asynchronous calls from the code to have accepted the client connection code to climbing in the database stops awaiting the data, and the event loop will run continue to service other threads and will check the readiness of the data for the next iteration.
Now I understand why the assignment is true.

That is, I can always rely on the fact that if coroutine needs data from another coroutine, the incident with the sequence of their execution will not happen?

What can you say about
To improve performance it is better to write corrucini small and tasks are broken up into a bunch of subroutines? or, on the contrary, it is better to push in one coroutine?
? - alisha.Harber commented on June 3rd 19 at 19:34
Garbage you write.


And what's the difference? in addition to async await and run eventloop's, of course. What will be the difference in the logic implementation? I peed a little and read the official guide - do the impression, like a code structure similar to what it looks like, for example, in the flask. - alisha.Harber commented on June 3rd 19 at 19:37
,
What can you say about

I will say that it is always a good practice, even in single-tasking code.

And what's the difference?

Wow, that's two words not to describe. But asynchronous code rarely for whom it is intuitive. More often only seem so. Multitasking in General just does not happen, wherever it was not implemented. - samir39 commented on June 3rd 19 at 19:40
I will say that it is always a good practice, even in single-tasking code.


Mean breaking tasks into small subroutines, as I understand. - alisha.Harber commented on June 3rd 19 at 19:43
and no matter what is the cause of the breaking - the organisation of the code or the context of its execution, the principle of sole responsibility in all cases fair. - samir39 commented on June 3rd 19 at 19:46

Find more questions by tags BackendAsynchronous programming