MYCSS

Показ дописів із міткою async. Показати всі дописи
Показ дописів із міткою async. Показати всі дописи

2024-12-25

Як завершити async-завдання, створене з функції що блокує через asyncio.to_thread(): експеримент та рішення.

Маленький експеримент як завершити async task якщо вона була створена з функції що блокує.

Тобто створена з не асинхронної функції (proc2) за допомогою asyncio.to_thread().

Як видно з результатів без використання threading.Event(), програма буде постійно працювати навіть після закінчення всіх асинхронних функцій в async loop, тому що окремий потік породжений у цій програмі ще не завершився й async loop буде чекати на нього.

2024-10-19

FastAPI Dependency Injection: 21 Examples Using Depends() with AI Answers

Why ?

Once I wanted to understand how Depends works in FastAPI more thoroughly to understand what's under the hood. I started communicating with the AI. The answer was a question, and I got hooked. 
I decided to test it in real code and created a training project and wrote this post for it based on my questions to the AI and its answers.
Some answers were wrong, some I had already optimized a bit. But all the results shown are real and created by me personally. 
The result was 21 training examples written in Python, where I checked the answers and suggestions from the AI.

 

Коли забув ти рідну мову, біднієш духом ти щодня...
When you forgot your native language you would become a poor at spirit every day ...

Д.Білоус / D.Bilous
Рабів до раю не пускають. Будь вільним!

ipv6 ready