问题
Operating system - Ubuntu Server 14.04 on Azure VM
Tried with different versions of python (3.4.3, 3.6.0), apache and mod_wsgi.
Installed MS Native ODBC driver using instructions from here https://gist.github.com/joecampo/6f777a659b8132b9d6fe1c3589df394c , while pyodbc was installed using pip.
To debug the wsgi_module I have set up the django application to run in embedded mode and:
gdb /usr/local/apache2/bin/httpd
run -X
When I access any function which imports pyodbc, the wsgi fails with the following error:
Program received signal SIGSEGV, Segmentation fault.
import_types () at src/pyodbcmodule.cpp:223
223 src/pyodbcmodule.cpp: No such file or directory.
Importing module works fine when I run the django app from the command line:
python3 manage.py runserver
Is there a workaround?
回答1:
I experienced the same problem when setting up a Python Pyramid project, and downgrading to a previous version of pyodbc fixed it.
It looks like this may be a bug in pyodbc or the WSGI module. See pyodbc 4.0.9+ segfault with uwsgi #199. You may already be aware that this line is a red herring:
223 src/pyodbcmodule.cpp: No such file or directory.
That error is coming from the debugger and just tells where in import_types() the exception was raised, however searching for that file led me to that bug report on GitHub.
You obviously already know how to debug Apache and wsgi, but for anyone who doesn't there are detailed instructions here.
回答2:
This has been fixed in 4.0.16 by adding support for subinterpreters.
来源:https://stackoverflow.com/questions/42374775/apache2-mod-wsgi-crashes-when-importing-pyodbc