Add a todo + some commented debug lines + foo_pep333.py enhancement

This commit is contained in:
Yann Weber 2019-08-06 17:20:54 +02:00
commit 7004f544e4
4 changed files with 24 additions and 2 deletions

View file

@ -1,8 +1,21 @@
import sys
import os
import time
from pprint import pformat
def entrypoint(env, start_response):
write_body = start_response("200 OK", [('Content-type', 'text/plain')])
write_body('Hello world !')
return ['Hello world !']
if not "wsgi.input" in env:
raise ValueError("Given environ does not contain any 'wsgi.input' key !")
data_in = env["wsgi.input"]
#for l in data_in:
# write_body("POST data line : %s" % repr(l))
#data = data_in.readlines()
while True:
data = data_in.read(98)
write_body("POST data : %s\n====\n" % repr(data))
if not data:
break
write_body("Environ data :\n'%s'\n====\n" % pformat(env))
return ['Hello world !\n']

View file

@ -152,6 +152,8 @@ void worker_piper_sighandler(int);
/**@brief empty pipes and log content for pep333 workers
* @todo enhance logging : 1 lines per logline + line counter ?
* @todo sys.stdout & sys.stderr can have an implementation like
* libpyfcgi.IoIn to avoir useless buffering
* @param int pipes for stdout
* @param int pipes for stderr
* @param PyObject[2] python flush methods

View file

@ -363,6 +363,7 @@ PyObject* pyfcgi_ioin_read(PyObject *self, PyObject **argv, Py_ssize_t argc)
break;
}
}
//dprintf(2, "read : %s\n", PyBytes_AsString(res));
Py_DECREF(res);
return res;
}

View file

@ -385,6 +385,12 @@ PyObject* update_pyenv(PyObject *py_osmod, char **environ)
PyDict_Update(pyenv, PyFCGI_conf.context.wsgi_dict);
PyObject_SetAttrString(py_osmod, "environ", pyenv);
/*//Debug print env on stderr
PyObject* repr = PyObject_ASCII(pyenv);
Py_INCREF(repr);
dprintf(2, "%s\n", PyUnicode_AsUTF8(repr));
Py_DECREF(repr);
*/
return pyenv;
}