# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.kurianbenoy.com/async-await/lesson-4-coroutines-in-hood.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
