diff options
author | Max Romanov <max.romanov@nginx.com> | 2021-07-20 10:37:54 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2021-07-20 10:37:54 +0300 |
commit | f27fbd9b4d2bdaddf1e7001d0d0bc5586ba04cd4 (patch) | |
tree | 1d1156008cfc59e14d643a3d66f83b56b7e35a7e /src/python/nxt_python.c | |
parent | dfbdc1c11a201e46d61f4bc61cfbe5741fc4fd70 (diff) | |
download | unit-f27fbd9b4d2bdaddf1e7001d0d0bc5586ba04cd4.tar.gz unit-f27fbd9b4d2bdaddf1e7001d0d0bc5586ba04cd4.tar.bz2 |
Python: using default event_loop for main thread for ASGI.
Unit's ASGI implementation creates a new event loop to run an application for
each thread since 542b5b8c0647. This may cause unexpected exceptions or
strange bugs if asyncio synchronisation primitives are initialised before the
application starts (e.g. globally).
Although the approach with a new event loop for the main thread is consistent
and helps to prepare the application to run in multiple threads, it can be a
source of pain for people who just want to run single-threaded ASGI
applications in Unit.
This is related to #560 issue on GitHub.
Diffstat (limited to 'src/python/nxt_python.c')
-rw-r--r-- | src/python/nxt_python.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/python/nxt_python.c b/src/python/nxt_python.c index 588a147a..bdce68b2 100644 --- a/src/python/nxt_python.c +++ b/src/python/nxt_python.c @@ -264,7 +264,7 @@ nxt_python_start(nxt_task_t *task, nxt_process_data_t *data) goto fail; } - rc = nxt_py_proto.ctx_data_alloc(&python_init.ctx_data); + rc = nxt_py_proto.ctx_data_alloc(&python_init.ctx_data, 1); if (nxt_slow_path(rc != NXT_UNIT_OK)) { goto fail; } @@ -504,7 +504,7 @@ nxt_python_init_threads(nxt_python_app_conf_t *c) for (i = 0; i < c->threads - 1; i++) { ti = &nxt_py_threads[i]; - res = nxt_py_proto.ctx_data_alloc(&ti->ctx_data); + res = nxt_py_proto.ctx_data_alloc(&ti->ctx_data, 0); if (nxt_slow_path(res != NXT_UNIT_OK)) { return NXT_UNIT_ERROR; } |