AsyncIO part 2: Threads, green threads, couroutins and The Event Loop.
By Taras Voinarovskyi
AsyncIO part 2: Threads, green threads, couroutins and The Event Loop.
Threads are bad, we can do it in a single thread and still get the same result. Well, yes, but why? What makes a thread fail in comparison to a coroutine and when? Socket handling in a loop is good for a simple echo server, but will not help us do a normal project. What features are needed for a normal socket server, that can also connect to a database, do complex processing, do background processing, read files and still retain 1 thread to do that all? Lets talk about delayed calls, transports, protocols and other parts that make up an event loop.