Tests about a simple python3 fastcgi runner using libfcgi and the Python-C API.
python
c
wsgi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2019 Weber Yann
  3. *
  4. * This file is part of PyFCGI.
  5. *
  6. * PyFCGI is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * PyFCGI is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with PyFCGI. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _PYUTILS__H__
  20. #define _PYUTILS__H__
  21. #include "config.h"
  22. #include <fcgiapp.h>
  23. #include <fcgi_stdio.h> /* fcgi library; put it first*/
  24. #define PY_SSIZE_T_CLEAN
  25. #include <Python.h>
  26. #include "logger.h"
  27. #include "python_pyfcgi.h"
  28. /* Imports from libpyfcgi python module header */
  29. extern PyObject* response_status;
  30. extern PyObject* response_headers;
  31. extern PyObject* libpyfcgi_self;
  32. /**@brief Call Py_Initialize & update_python_path
  33. */
  34. void pyinit();
  35. /**@brief Add . to the embed pythonpath
  36. * @deprecated Py_SetPath breaks Py_GetPrefix()... now
  37. */
  38. void update_python_path();
  39. /**@brief Fetch stdout & stderr python flush() function
  40. * @param PyObject* pystdout_flush
  41. * @param PyObject* pystderr_flush
  42. */
  43. void fetch_pyflush(PyObject**, PyObject**);
  44. /**@brief Create two pipes for stdout & stderr
  45. * @ingroup worker_process
  46. * @params int[2] pystdout
  47. * @params int[2] pystderr
  48. */
  49. void update_python_fd(int[2], int[2]);
  50. /**@brief Clear then update python sys.environ using current FCI environ
  51. * @ingroup worker_process
  52. * @note The environ has to be set without a call to os.putenv, the problem
  53. * is that the os.environ is a special mapping calling putenv on setitem...
  54. * For these reason the os.environ will be replaced by a new dict instance for
  55. * each request...
  56. * @param PyObject* os module
  57. * @return Python env dict
  58. */
  59. PyObject* update_pyenv(PyObject*, char**);
  60. /**@brief Import & return the python entrypoint callable
  61. * from PyFCGI_conf.py_entrymod & PyFCGI_conf.py_entryfun */
  62. PyObject* import_entrypoint();
  63. /**@brief Return the start_response() python function for pep333 worker */
  64. PyObject* get_start_response();
  65. /**@brief Logs an exception */
  66. void log_expt(int priority);
  67. /**@brief Set python version
  68. * @param char[16] version buffer */
  69. void pyfcgi_python_version(char[16]);
  70. /**@brief Import os module and exit on error
  71. * @return Imported module */
  72. PyObject* python_osmod();
  73. #endif