Files
uwsgi/plugins/python/gil.c
2011-08-31 13:18:32 +02:00

38 lines
831 B
C

#include "uwsgi_python.h"
extern struct uwsgi_server uwsgi;
extern struct uwsgi_python up;
#ifdef UWSGI_PYPY
void gil_real_get() {}
void gil_real_release() {}
#else
void gil_real_get() {
//uwsgi_log("LOCK %d\n", uwsgi.mywid);
#ifndef PYTHREE
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);
#ifndef PYTHREE
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
}
#endif
void gil_fake_get() {}
void gil_fake_release() {}