Reputation: 69
Im trying to develop a flask application with gunicorn, since gunicorn is implemented in python (i checked github). My question are gunicorn's threads or under GIL ?
Upvotes: 5
Views: 1670
Reputation: 33577
The threads are actually always real. The issue, as you point out, is that if there is a global interpreter lock (GIL) in place, the interpreter gets locked while it's interpreting Python, preventing threads from working simultaneously. Since Gunicorn is written in Python, it's bound by the laws of whatever Python implementation you're using, which may have a GIL.
Both CPython and PyPy have a GIL, but that doesn't mean threading is useless. For as long as whats being executed doesn't require interpretation (e.g. I/O operations), multiple threads can be used without locking.
See the lovely answer on how a Python thread work for details.
Upvotes: 6