mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-04 04:31:44 +00:00
add new files to the tree
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
#include "uwsgi_python.h"
|
||||
|
||||
extern struct uwsgi_server uwsgi;
|
||||
extern struct uwsgi_python up;
|
||||
|
||||
int manage_python_response(struct wsgi_request *wsgi_req) {
|
||||
// use standard WSGI response parse
|
||||
return uwsgi_response_subhandler_wsgi(wsgi_req);
|
||||
}
|
||||
|
||||
PyObject *python_call(PyObject *callable, PyObject *args, int catch) {
|
||||
|
||||
PyObject *pyret;
|
||||
|
||||
uwsgi_log("CALLING %p %p\n", callable, args);
|
||||
pyret = PyEval_CallObject(callable, args);
|
||||
uwsgi_log("CALLED\n");
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
if (!catch) {
|
||||
PyErr_Print();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef UWSGI_DEBUG
|
||||
if (pyret) {
|
||||
uwsgi_debug("called %p %p %d\n", callable, args, pyret->ob_refcnt);
|
||||
}
|
||||
#endif
|
||||
|
||||
uwsgi_log("called\n");
|
||||
|
||||
return pyret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uwsgi_python_call(struct wsgi_request *wsgi_req, PyObject *callable, PyObject *args) {
|
||||
|
||||
wsgi_req->async_result = python_call(callable, args, 0);
|
||||
|
||||
if (wsgi_req->async_result) {
|
||||
while ( manage_python_response(wsgi_req) != UWSGI_OK) {
|
||||
#ifdef UWSGI_ASYNC
|
||||
if (uwsgi.async > 1) {
|
||||
return UWSGI_AGAIN;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return UWSGI_OK;
|
||||
}
|
||||
|
||||
void init_pyargv() {
|
||||
|
||||
char *ap;
|
||||
|
||||
#ifdef PYTHREE
|
||||
wchar_t pname[6];
|
||||
mbstowcs(pname, "uwsgi", 6);
|
||||
uwsgi.py_argv[0] = pname;
|
||||
#else
|
||||
uwsgi.py_argv[0] = "uwsgi";
|
||||
#endif
|
||||
|
||||
if (up.argv != NULL && !up.argc) {
|
||||
up.argc++;
|
||||
#ifdef PYTHREE
|
||||
wchar_t *wcargv = malloc( sizeof( wchar_t ) * (strlen(up.argv)+1));
|
||||
if (!wcargv) {
|
||||
uwsgi_error("malloc()");
|
||||
exit(1);
|
||||
}
|
||||
memset(wcargv, 0, sizeof( wchar_t ) * (strlen(up.argv)+1));
|
||||
#endif
|
||||
|
||||
#ifdef __sun__
|
||||
// FIX THIS !!!
|
||||
ap = strtok(up.argv, " ");
|
||||
while ((ap = strtok(NULL, " ")) != NULL) {
|
||||
#else
|
||||
while ((ap = strsep(&up.argv, " \t")) != NULL) {
|
||||
#endif
|
||||
if (*ap != '\0') {
|
||||
#ifdef PYTHREE
|
||||
mbstowcs( wcargv + strlen(ap), ap, strlen(ap));
|
||||
uwsgi.py_argv[up.argc] = wcargv + strlen(ap);
|
||||
#else
|
||||
uwsgi.py_argv[up.argc] = ap;
|
||||
#endif
|
||||
up.argc++;
|
||||
}
|
||||
if (up.argc + 1 > MAX_PYARGV)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PySys_SetArgv(up.argc, &up.argv);
|
||||
}
|
||||
Reference in New Issue
Block a user