Fuck me on GayHub

# How coroutine works internally [Drafting]

Coroutines are generalization of subroutines. they are used for cooperative multitasking where a process voluntarily yield(give away) control periodically or when idle in order to enable multiple applications to be run simultaneously. compare to thread, coroutine is context-swtich in User space by programming language or by programmer itself, but thread is managed by OS. but anyway, do you know how Python implements coroutine? or how can it yield control away and lately resume back?

# Python Dict: a new implementation by pure Python

Python have builtin implementation for dict, which is used to store key-value and also provided other related operations. Due to it is an frequenctly used basic data type, here I will use pure Python implement an dict.

# Gevent: patch it and pray

To speedup the IO related operations in our project, we use Gevent and patch_all in Django. but it also makes project more complicated, especially when a new maintainer trying to figure out how the multi-threading process works without knowing the patch. So Guido van Rossum once said: when you use gevent in your project, once after patch, god knows what will happen later. i.e Patch it and Pray!!! and also for other reasons, this way isn’t a Pythonic way. here in this post, let’s see how it works, why it is bad.

# Gunicorn, an inside view of it

Gunicorn 是一个Python Web Server实现，兼容WSGI协议。其迁移自Ruby世界的Unicorn。在我们的生产环境中，有大量使用Gunicorn作为Web 服务器，所以本文分析Gunicorn的相关几个问题： Server model，Async worker.

# Let's build a WSGI server

Let’s build a wsgi server ground up with sockets, multi-processing or Select/Poll/Epoll. to achive this, you need familiar with Python’s socket programming, Python’s cucurreny model, Linux Non-blocking I/O.