From 091916614539c01e571486f2a55c68f87bd435bf Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Tue, 13 Oct 2020 01:37:39 +0300 Subject: Fixed building with Python 3.9. PyUnicode_GET_SIZE() in deprecated since 3.3 and will be removed in 3.12. In version 3.9 it was explicitly marked by deprecation warning causing compilation error with Unit. PyUnicode_GET_LENGTH() must be used instead. --- src/python/nxt_python.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/python/nxt_python.h') diff --git a/src/python/nxt_python.h b/src/python/nxt_python.h index 3211026b..3dd04e31 100644 --- a/src/python/nxt_python.h +++ b/src/python/nxt_python.h @@ -28,6 +28,7 @@ #define PyBytes_AS_STRING PyString_AS_STRING #define PyUnicode_InternInPlace PyString_InternInPlace #define PyUnicode_AsUTF8 PyString_AS_STRING +#define PyUnicode_GET_LENGTH PyUnicode_GET_SIZE #endif #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 5 -- cgit From 4225361f0ea7d230c80209d76fbc67a932651380 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Thu, 5 Nov 2020 00:04:58 +0300 Subject: Python: introducting macro to simplify minor version check. --- src/python/nxt_python.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/python/nxt_python.h') diff --git a/src/python/nxt_python.h b/src/python/nxt_python.h index 3dd04e31..6d7eba8e 100644 --- a/src/python/nxt_python.h +++ b/src/python/nxt_python.h @@ -11,6 +11,8 @@ #include #include +#define NXT_PYTHON_VER(maj, min) ((maj << 24) | (min << 16)) + #if PY_MAJOR_VERSION == 3 #define NXT_PYTHON_BYTES_TYPE "bytestring" @@ -31,7 +33,7 @@ #define PyUnicode_GET_LENGTH PyUnicode_GET_SIZE #endif -#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 5 +#if PY_VERSION_HEX >= NXT_PYTHON_VER(3, 5) #define NXT_HAVE_ASGI 1 #endif -- cgit From 8dcb0b9987033d0349a6ecf528014a9daa574787 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Thu, 5 Nov 2020 00:04:59 +0300 Subject: Python: request processing in multiple threads. This closes #459 issue on GitHub. --- src/python/nxt_python.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/python/nxt_python.h') diff --git a/src/python/nxt_python.h b/src/python/nxt_python.h index 6d7eba8e..b581dd46 100644 --- a/src/python/nxt_python.h +++ b/src/python/nxt_python.h @@ -44,20 +44,25 @@ typedef struct { PyObject **object_p; } nxt_python_string_t; +typedef struct { + int (*ctx_data_alloc)(void **pdata); + void (*ctx_data_free)(void *data); + int (*startup)(void *data); + int (*run)(nxt_unit_ctx_t *ctx); + int (*ready)(nxt_unit_ctx_t *ctx); + void (*done)(void); +} nxt_python_proto_t; + -nxt_int_t nxt_python_init_strings(nxt_python_string_t *pstr); +int nxt_python_init_strings(nxt_python_string_t *pstr); void nxt_python_done_strings(nxt_python_string_t *pstr); void nxt_python_print_exception(void); -nxt_int_t nxt_python_wsgi_init(nxt_task_t *task, nxt_unit_init_t *init); -int nxt_python_wsgi_run(nxt_unit_ctx_t *ctx); -void nxt_python_wsgi_done(void); +int nxt_python_wsgi_init(nxt_unit_init_t *init, nxt_python_proto_t *proto); int nxt_python_asgi_check(PyObject *obj); -nxt_int_t nxt_python_asgi_init(nxt_task_t *task, nxt_unit_init_t *init); -nxt_int_t nxt_python_asgi_run(nxt_unit_ctx_t *ctx); -void nxt_python_asgi_done(void); +int nxt_python_asgi_init(nxt_unit_init_t *init, nxt_python_proto_t *proto); #endif /* _NXT_PYTHON_H_INCLUDED_ */ -- cgit