> For the complete documentation index, see [llms.txt](https://til.kurianbenoy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.kurianbenoy.com/async-await/lesson-4-coroutines-in-hood.md).

# Lesson 4- coroutines in hood

Future object can report whether the object is actually being completed or really done

![](/files/-MiXaIVBv0TEq1fsvw9Q)

* It's called the promises, deferred in other languages

We looked at about awaitables in asyncio

* coroutines
* tasks
* futures

On looking code implementation of coroutines, it's just simply a generator function. Learned about generators properties like next, fstate etc.

coroutine is just a normal generators, while tasks also doesn't have anything special.

The special functionality is implemented actually really in tasks, where it's calling a loop which calls one callback to another with multiple send loops

![](/files/-MjQRiOjMLE7FkYwCKLT)

In python3, the default implementation is in C, while python implementation is there which is exactly copied in C as well.

**Most common pitfall in asyncio**

![](/files/-MjQS6O46dV7O0hwasNa)

![](/files/-MjQSNKf0_3mTAYp9kC-)

Forgetting await with coroutiens. Using type hinting

![](/files/-MjQSYH726ROXyE-h0M7)

Holding long task, the blocking should never happen in asyncio

Network lattency in servers. When running 1000 asyncio clients, it's better handling than in other ways.
