# Lesson 4- coroutines in hood

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

![](https://4253921594-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhiOx8KkYnYxHHqfUbB%2F-MiX_gtQ2vHzImdPA0PO%2F-MiXaIVBv0TEq1fsvw9Q%2Fimage.png?alt=media\&token=c02eaf14-c431-4944-978b-a81ea1182d00)

* 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

![](https://4253921594-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhiOx8KkYnYxHHqfUbB%2F-MjQRRMQIAeX2gxEwzsz%2F-MjQRiOjMLE7FkYwCKLT%2Fimage.png?alt=media\&token=897103ba-7bb9-496a-9923-1950e1aa2220)

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**

![](https://4253921594-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhiOx8KkYnYxHHqfUbB%2F-MjQRzf63O8aMy1g_wQe%2F-MjQS6O46dV7O0hwasNa%2Fimage.png?alt=media\&token=01a5c7da-70b3-4e56-b569-d2e3d26c0d06)

![](https://4253921594-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhiOx8KkYnYxHHqfUbB%2F-MjQRzf63O8aMy1g_wQe%2F-MjQSNKf0_3mTAYp9kC-%2Fimage.png?alt=media\&token=0e7f9e79-69bb-4dfb-ac16-e862f53fc189)

Forgetting await with coroutiens. Using type hinting

![](https://4253921594-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhiOx8KkYnYxHHqfUbB%2F-MjQRzf63O8aMy1g_wQe%2F-MjQSYH726ROXyE-h0M7%2Fimage.png?alt=media\&token=83b824e2-7821-4000-8e95-302e1c144232)

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.
