summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_python_wsgi.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-07-31Isolation: fixed the generation of mounts table.Tiago Natel de Moura1-8/+4
Since the introduction of rootfs feature, some language modules can't be configured multiple times. Now the configure generates a separate nxt_<module>_mounts.h for each module compiled.
2020-07-24Configuration: added checking for presence of mandatory fields.Valentin Bartenev1-5/+0
2020-05-28Added "rootfs" feature.Tiago Natel de Moura1-0/+9
2020-03-09Refactor of process management.Tiago Natel de Moura1-5/+8
The process abstraction has changed to: setup(task, process) start(task, process_data) prefork(task, process, mp) The prefork() occurs in the main process right before fork. The file src/nxt_main_process.c is completely free of process specific logic. The creation of a process now supports a PROCESS_CREATED state. The The setup() function of each process can set its state to either created or ready. If created, a MSG_PROCESS_CREATED is sent to main process, where external setup can be done (required for rootfs under container). The core processes (discovery, controller and router) doesn't need external setup, then they all proceeds to their start() function straight away. In the case of applications, the load of the module happens at the process setup() time and The module's init() function has changed to be the start() of the process. The module API has changed to: setup(task, process, conf) start(task, data) As a direct benefit of the PROCESS_CREATED message, the clone(2) of processes using pid namespaces now doesn't need to create a pipe to make the child block until parent setup uid/gid mappings nor it needs to receive the child pid.
2020-03-12Python: implementing input readline and line iterator.Max Romanov1-2/+145
2019-12-24Adding "limits/shm" configuration validation and parsing.Max Romanov1-0/+1
2019-12-23Python: pre-creation of objects for string constants.Valentin Bartenev1-38/+156
This is an optimization to avoid creating them at runtime on each request.
2019-11-14Python: avoiding buffering of exception backtraces.Valentin Bartenev1-7/+47
A quote from the Python 3 documentation: | When interactive, stdout and stderr streams are line-buffered. | Otherwise, they are block-buffered like regular text files. As a result, if an exception occurred and PyErr_Print() was called, its output could be buffered but not printed to the log for a while (ultimately, until the interpreter finalization). If the application process crashed shortly, the backtrace was completely lost. Buffering can be disabled by redefining the sys.stderr stream object. However, interference with standard environment objects was deemed undesirable. Instead, sys.stderr.flush() is called every time after printing exceptions. A potential advantage here is that lines from backtraces won't be mixed with other lines in the log.
2019-11-14Python: removed wrong PyErr_Print() call.Valentin Bartenev1-1/+0
PyCallable_Check() doesn't produce errors. The needless call was introduced in fdd6ed28e3b9.
2019-11-14Python: optimized response object close() calling.Valentin Bartenev1-7/+14
PyObject_HasAttrString() is just a wrapper over PyObject_GetAttrString(), while PyObject_CallMethod() calls it as the first step. As a result, PyObject_GetAttrString() was called twice if close() was present. To get rid of PyObject_HasAttrString() while keeping the same behaviour, the PyObject_CallMethod() call has been decomposed into separate calls of PyObject_GetAttrString() and PyObject_CallFunction().
2019-11-14Python: fixed an object leak when response close() is called.Valentin Bartenev1-10/+19
On success, PyObject_CallMethod() returns a new reference to the result of the call, which previously got lost. Also, error logging on failure was added. The issue was introduced by b0148ec28c4d.
2019-11-14Python: refactored nxt_python_request_handler().Valentin Bartenev1-56/+31
2019-11-14Python: fixed potential object leak in case of allocation error.Valentin Bartenev1-0/+2
2019-11-14Python: improved error handling if response object isn't iterable.Valentin Bartenev1-0/+1
According to the documentation, PyObject_GetIter(): | Raises TypeError and returns NULL if the object cannot be iterated. Previously, this exception wasn't printed or cleared and remained unhandled.
2019-11-14Python: fixed handling of errors on response object iteration.Valentin Bartenev1-8/+15
According to the documentation, PyIter_Next(): | If there are no remaining values, returns NULL with no exception set. | If an error occurs while retrieving the item, returns NULL and passes | along the exception. Previously, this exception wasn't properly handled and the response was finalized as successful. This issue was introduced in b0148ec28c4d. A check for PyErr_Occurred() located in the code below might print this traceback or occasionally catch an exception from one of the two response close() calls. Albeit that exceptions from the close() calls also need to be catched, it's clear that this particular check wasn't supposed to do so. This is another issue and it will be fixed later.
2019-11-13Python: releasing GIL while waiting for a request.Valentin Bartenev1-15/+23
It unblocks other threads that can be forked by the application to work in background. This closes #336 issue on GitHub.
2019-10-23Python: fixing Python 3.8 build with clang.Max Romanov1-53/+7
Python 3.8 has 'tp_print' field in PyTypeObject struct. This field is attributed as deprecated. So, clang generates warning (which is turned to error) as a result of initializing this field. From the other hand, it is impossible to omit this field in positional initialization. The solution is to use designated initializer. Silencing usage message during configure python. This is related to #331 issue on GitHub.
2019-10-22Python: fixing build for Python 3.8.Max Romanov1-0/+4
Thanks to tonyafanasyev. This is related to #331 issue on GitHub.
2019-03-21Adjusting request schema value according to connection tls state.Max Romanov1-20/+7
This closes #223 issue on GitHub.
2019-02-28Made QUERY_STRING mandatory.Valentin Bartenev1-5/+1
According to CGI/1.1 RFC 3875: The server MUST set this variable; if the Script-URI does not include a query component, the QUERY_STRING MUST be defined as an empty string (""). Python's PEP 333(3) allows omitting it in WSGI interface; PHP docs force no requirements; PSGI and Rack specifications require it even if empty. When nginx proxies requests over FastCGI, it always provides QUERY_STRING. and some PHP apps have been observed to fail if it is missing (see issue #201 on GitHub). A drawback of this change (besides a small overhead) is that there will be no easy way to tell a missing query string from an empty one (i.e. requests with or without the "?" character); yet, it's negligible compared to the possible benefits of wider application compatibility. This closes #226 issue on GitHub.
2019-02-28Introducing Java Servlet Container beta.Max Romanov1-0/+1
2019-02-27Fixed processing of SERVER_NAME after 77aad2c142a0.Valentin Bartenev1-21/+8
Previously, the nxt_router_prepare_msg() function expected server host among other headers unmodified. It's not true anymore since normalization of the Host header has been introduced in 77aad2c142a0. The nxt_unit_split_host() function was removed. It didn't work correctly with IPv6 literals. Anyway, after 77aad2c142a0 the port splitting is done in router while Host header processing.
2018-12-20Python: fixed error reporting on initialization of applications.Valentin Bartenev1-11/+10
PyErr_Print() writes traceback to "sys.stderr", which is a file object that can buffer the output. If the process exits immediately, the buffer can be destroyed before flushing to the log. As a result, the user doesn't see the traceback. Now Py_Finalize() is also called in case of any errors during initialization. It finalizes the interpreter and flushes all data.
2018-12-20Python: cleanup of nxt_python_init().Valentin Bartenev1-10/+3
- Removed surplus NULL assignments; - Added missing nxt_slow_path(); - Style cleanup.
2018-12-20Python: fixed a typo in path error message.Artem Konev1-1/+1
2018-12-19Python: replaced PyErr_PrintEx(1) with PyErr_Print().Valentin Bartenev1-4/+4
These function calls are equivalent. No functional changes.
2018-09-20Python: adjusted input.read(size) argument value interpretation.Valentin Bartenev1-3/+5
Previously, passing 0 resulted in reading the whole body and all negative values raised an exception. Now the behaviour is in consistentance with io.RawIOBase.read() interface, and passing 0 returns empty (byte) string, while -1 results in reading the whole body.
2018-08-06Python: decoding unicode strings as Latin1.Max Romanov1-5/+6
According to PEP 3333, header names and values should be decoded as Latin1.
2018-08-06Unit application library.Max Romanov1-275/+397
Library now used in all language modules. Old 'nxt_app_*' code removed. See src/test/nxt_unit_app_test.c for usage sample.
2018-06-25Introduced nxt_length() macro.Valentin Bartenev1-5/+5
2018-05-21Added SERVER_SOFTWARE request meta-variable.Valentin Bartenev1-0/+18
2018-04-25Python: added a missing slash in the path to "pyenv.cfg".Valentin Bartenev1-1/+1
This closes #115 issue on GitHub.
2018-04-24Support for PEP 405 virtual environments.Valentin Bartenev1-8/+50
This closes #96 issue on GitHub.
2018-04-19Python: returning write() callable object from start_response().Alexander Borisov1-1/+47
According to PEP (3)333 the start_respose() function must return a write() callable. This closes #107 issue on GitHub.
2018-04-04Changed version processing for modules.Alexander Borisov1-1/+1
2018-03-15Python: safety checks for request processing context.Valentin Bartenev1-2/+14
An application can store request related functions and mistakenly call them outside of request processing. Previously this resulted in segmentation fault due to unset nxt_python_run_ctx. Now an exception will be raised.
2018-03-15Python: fixed crash if start_response() is called inside iteration.Valentin Bartenev1-4/+4
The start_response() uses nxt_python_run_ctx, but it was unset right after the application call.
2018-03-05Reduced number of critical log levels.Valentin Bartenev1-41/+34
2018-01-19Python: fixed the "wsgi.errors" environment variable name.Valentin Bartenev1-2/+2
This closes issue #76 on GitHub.
2017-12-28Removed duplicate declaration.Igor Sysoev1-1/+1
2017-12-28HTTP keep-alive connections support.Igor Sysoev1-8/+2
2017-12-27Introducing application 'atexit' hook.Max Romanov1-1/+17
Finalizing Python interpreter. This closes #65 issue on GitHub.
2017-11-29Introducing python virtualenv configuration.Max Romanov1-0/+30
New parameter 'home' for python application allows to configure application-specific virtualenv path. This closes #15 issue on GitHub.
2017-11-20Fixing Coverity warnings.Max Romanov1-2/+2
CID 200496 CID 200494 CID 200490 CID 200489 CID 200483 CID 200482 CID 200472 CID 200465
2017-10-18Added the debug option to module compatibility vector.Igor Sysoev1-1/+1
2017-09-06Style fixes.Igor Sysoev1-2/+4
2017-09-01Added SERVER_ADDR parameter for Python and PHP modules.Igor Sysoev1-0/+1
2017-08-31nginext has been renamed to unit.Igor Sysoev1-5/+5
2017-08-31Introduced module compatibility vector.Igor Sysoev1-0/+7
2017-08-17The new module configuration interface.Igor Sysoev1-103/+4
Configuration and building example: ./configure ./configure python ./configure php ./configure go make all or ./configure make nginext ./configure python make python ./configure php make php ./configure go make go Modules configuration options and building examples: ./configure python --module=python2 --config=python2.7-config make python2 ./configure php --module=php7 --config=php7.0-config --lib-path=/usr/local/php7.0 make php7 ./configure go --go=go1.6 --go-path=${HOME}/go1.6 make go1.6