-
Notifications
You must be signed in to change notification settings - Fork 687
/
gil.c
31 lines (25 loc) · 809 Bytes
/
gil.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "uwsgi_python.h"
extern struct uwsgi_server uwsgi;
extern struct uwsgi_python up;
void gil_real_get() {
//uwsgi_log("LOCK %d\n", uwsgi.mywid);
#if !defined(PYTHREE) && !defined(UWSGI_PYPY)
PyEval_AcquireLock();
PyThreadState_Swap((PyThreadState *) pthread_getspecific(up.upt_gil_key));
#else
PyEval_RestoreThread((PyThreadState *) pthread_getspecific(up.upt_gil_key));
#endif
//uwsgi_log("LOCKED !!! %d\n", uwsgi.mywid);
}
void gil_real_release() {
//uwsgi_log("UNLOCK %d\n", uwsgi.mywid);
#if !defined(PYTHREE) && !defined(UWSGI_PYPY)
pthread_setspecific(up.upt_gil_key, (void *) PyThreadState_Swap(NULL));
PyEval_ReleaseLock();
#else
pthread_setspecific(up.upt_gil_key, (void *) PyThreadState_Get());
PyEval_SaveThread();
#endif
}
void gil_fake_get() {}
void gil_fake_release() {}