Closed opensemanticsearch closed 5 years ago
I set the wsgi config for Apache2 to daemon mode, now it works for first IP every time, but calls from another IP get the internal server error every time:
/var/log/apache2/error.log:
[Fri Jul 19 13:42:35.021155 2019] [wsgi:error] [pid 1198] [remote 10.0.2.2:53382] mod_wsgi (pid=1198): Failed to exec Python script file '/var/lib/opensemanticsearch/opensemanticsearch/wsgi.py'.
[Fri Jul 19 13:42:35.021237 2019] [wsgi:error] [pid 1198] [remote 10.0.2.2:53382] mod_wsgi (pid=1198): Exception occurred processing WSGI script '/var/lib/opensemanticsearch/opensemanticsearch/wsgi.py'.
[Fri Jul 19 13:42:35.021417 2019] [wsgi:error] [pid 1198] [remote 10.0.2.2:53382] Traceback (most recent call last):
[Fri Jul 19 13:42:35.021475 2019] [wsgi:error] [pid 1198] [remote 10.0.2.2:53382] File "/var/lib/opensemanticsearch/opensemanticsearch/wsgi.py", line 14, in
After temporary removing of complex (many dependencies) external import-export-app (throwing (maybe same problem) an error importing numpy) following more OSS specific error on second IP:
Traceback:
File "/usr/lib/python3/dist-packages/django/core/handlers/exception.py" in inner
File "/usr/lib/python3/dist-packages/django/core/handlers/base.py" in _legacy_get_response
File "/usr/lib/python3/dist-packages/django/middleware/common.py" in process_request
File "/usr/lib/python3/dist-packages/django/middleware/common.py" in should_redirect_with_slash
File "/usr/lib/python3/dist-packages/django/urls/base.py" in is_valid_path
File "/usr/lib/python3/dist-packages/django/urls/base.py" in resolve
File "/usr/lib/python3/dist-packages/django/urls/resolvers.py" in resolve
File "/usr/lib/python3/dist-packages/django/utils/functional.py" in get
File "/usr/lib/python3/dist-packages/django/urls/resolvers.py" in url_patterns
File "/usr/lib/python3/dist-packages/django/utils/functional.py" in get
File "/usr/lib/python3/dist-packages/django/urls/resolvers.py" in urlconf_module
File "/usr/lib/python3.7/importlib/init.py" in import_module
File "/var/lib/opensemanticsearch/opensemanticsearch/urls.py" in
File "/usr/lib/python3/dist-packages/django/conf/urls/init.py" in include
File "/usr/lib/python3.7/importlib/init.py" in import_module
File "/var/lib/opensemanticsearch/api/urls.py" in
File "/var/lib/opensemanticsearch/api/views.py" in
File "/usr/lib/python3/dist-packages/opensemanticetl/tasks.py" in
File "/usr/lib/python3/dist-packages/opensemanticetl/etl_web.py" in
Exception Type: ImportError at /files/recrawl Exception Value: Interpreter change detected - this module can only be loaded into one interpreter per process.
WSGIApplicationGroup %{GLOBAL} in apache config seems to solve it.
Documentation from https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIApplicationGroup.html
%{GLOBAL}
The application group name will be set to the empty string.
Any WSGI applications in the global application group will always be executed within the context of the first interpreter created by Python when it is initialised, of the process handling the request. Forcing a WSGI application to run within the first interpreter can be necessary when a third party C extension module for Python has used the simplified threading API for manipulation of the Python GIL and thus will not run correctly within any additional sub interpreters created by Python.
Changed preconfigured Apache wsgi config of the package in https://github.com/opensemanticsearch/open-semantic-search-apps/commit/9f4e2d710b44cb0b6914710058ee43fe5716ec06
(Seems especially on newer Debian releases or current installations maybe because newer releases of some dependencies like Debian and/or PIP packages) there is sometimes a "Internal Server Error" but not on every call, so sometimes you have to do multiple/many calls to reproduce it.
Maybe dependency hell of PIP/debian packages? Or an (after evolution of some Python packages using new/other features) now unstable Apache2 config?
Trying to setup WSGI module of Apache to daemon mode (which is recommended by Django).