mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-04 20:51:29 +00:00
fix multiple python mountpoints with multiple threads in cow mode
This commit is contained in:
@@ -325,12 +325,19 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, PyThre
|
||||
if (uwsgi.threads > 1 && id) {
|
||||
// if we have multiple threads we need to initialize a PyThreadState for each one
|
||||
for(i=0;i<uwsgi.threads;i++) {
|
||||
//uwsgi_log("%p\n", uwsgi.core[i]->ts[id]);
|
||||
uwsgi.workers[uwsgi.mywid].cores[i].ts[id] = PyThreadState_New( ((PyThreadState *)wi->interpreter)->interp);
|
||||
//uwsgi_log("%p\n", uwsgi.workers[uwsgi.mywid].cores[i].ts[id]);
|
||||
if (!uwsgi.workers[uwsgi.mywid].cores[i].ts[id]) {
|
||||
uwsgi_log("unable to allocate new PyThreadState structure for app %s", wi->mountpoint);
|
||||
goto doh;
|
||||
}
|
||||
// cow ?
|
||||
if (uwsgi.mywid == 0) {
|
||||
int j;
|
||||
for(j=1;j<=uwsgi.numproc;j++) {
|
||||
uwsgi.workers[j].cores[i].ts[id] = uwsgi.workers[0].cores[i].ts[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
PyThreadState_Swap((PyThreadState *) pthread_getspecific(up.upt_save_key) );
|
||||
}
|
||||
|
||||
@@ -920,12 +920,16 @@ int uwsgi_python_mount_app(char *mountpoint, char *app) {
|
||||
if (strchr(app, ':') || uwsgi_endswith(app, ".py") || uwsgi_endswith(app, ".wsgi")) {
|
||||
uwsgi.wsgi_req->appid = mountpoint;
|
||||
uwsgi.wsgi_req->appid_len = strlen(mountpoint);
|
||||
// lazy ?
|
||||
if (uwsgi.mywid > 0) UWSGI_GET_GIL
|
||||
if (uwsgi.single_interpreter) {
|
||||
id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, up.main_thread, PYTHON_APP_TYPE_WSGI);
|
||||
}
|
||||
else {
|
||||
id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, NULL, PYTHON_APP_TYPE_WSGI);
|
||||
}
|
||||
// lazy ?
|
||||
if (uwsgi.mywid > 0) UWSGI_RELEASE_GIL
|
||||
return id;
|
||||
}
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user