Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How uWSGI disable Python GIL

Tags:

python

uwsgi

In uWSGi document, there is a sentence said, If you start uWSGI without threads, the Python GIL will not be enabled, so threads generated by your application will never run

I wonder how uWSGi disable python GIL?

like image 295
Jacky1205 Avatar asked Mar 05 '16 04:03

Jacky1205


1 Answers

It replaces the functions for getting and releasing GIL (they handle switching threads) with a dummy functions doing nothing. See related source code:

Initializing thread switching to dummy by default:

https://github.com/unbit/uwsgi/blob/edb93f6c174a61858be88c9c2eb2c34bf87ae07d/plugins/python/python_plugin.c#L309-L311

Dummy GIL functions:

https://github.com/unbit/uwsgi/blob/abac960e62700117cb96af3cd22e27e04242e096/plugins/python/gil.c

like image 65
yedpodtrzitko Avatar answered Nov 06 '22 11:11

yedpodtrzitko