是什么原因导致Django在运行服务器中查询模型时看到错误,但是可以在交互式shell中以完全相同的方式查询同一模型却看不到错误?
这是我使用标准库中的faulthandler模块进行的分段故障回溯:
Fatal Python error: Segmentation fault
当前线程0x00007f8e533cb700(最近一次调用优先): 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/sql_server/pyodbc/base.py”,get_new_connection中的第307行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/backends/base/base.py”,连接中的第194行 确保文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/backends/base/base.py”,第216行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/backends/base/base.py”,_cursor中的第232行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/backends/base/base.py”,光标所在的第255行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/backends/base/base.py”,临时连接中的第577行 输入中的文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/contextlib.py”,第59行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/sql_server/pyodbc/base.py”,sql_server_version中的第390行 获取中的文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/functional.py” 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/sql_server/pyodbc/compiler.py”,as_sql中的第176行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/models/sql/compiler.py”,execute_sql中的第1052行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/models/query.py”, iter 中的第54行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/models/query.py”,_fetch_all中的第1186行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/db/models/query.py”, iter 中的第268行 在获取文件的第213行中添加文件“ /home/myUser/Projects/myProject/ReportApp/api/reports.py” 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/rest_framework/views.py”,分配中的第492行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/views/generic/base.py”,第68行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/views/decorators/csrf.py”,wrapped_view中的第54行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/base.py”,_get_response中的第124行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/deprecation.py”,调用中的第91行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/deprecation.py”,调用中的第91行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/deprecation.py”,调用中的第91行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/deprecation.py”,调用中的第91行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/deprecation.py”,调用中的第91行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/deprecation.py”,调用中的第91行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/deprecation.py”,调用中的第91行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/deprecation.py”,调用中的第91行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/exception.py”,内部第34行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/base.py”,get_response中的第78行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/handlers/wsgi.py”,调用中的第142行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/contrib/staticfiles/handlers.py”,调用中的第65行 文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/wsgiref/handlers.py”,运行中的第137行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/servers/basehttp.py”,handle_one_request中的第194行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/servers/basehttp.py”,句柄中的第169行 init 中的文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/socketserver.py”,第681行 文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/socketserver.py”,finish_request中的第354行 文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/socketserver.py”,process_request_thread中的第625行 运行中的文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/threading.py”,行862 _bootstrap_inner中的文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/threading.py”,第914行 _bootstrap中的文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/threading.py”,第882行
线程0x00007f8e59eae700(最近调用优先): 文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/selectors.py”,在选择中的第376行 文件“ /home/myUser/.pyenv/versions/3.5.4/lib/python3.5/socketserver.py”,serve_forever中的第232行 运行中的文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/servers/basehttp.py” 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/management/commands/runserver.py”,internal_run中的第139行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/autoreload.py”,包装中的第225行
线程0x00007f8e626c2700(最近调用优先): reloader_thread的第279行“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/autoreload.py” 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/autoreload.py”,python_reloader中的302行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/utils/autoreload.py”,主行323行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/management/commands/runserver.py”,运行中的第102行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/management/commands/runserver.py”,句柄中的第95行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/management/base.py”,执行行353 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/management/commands/runserver.py”,执行第60行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/management/base.py”,run_from_argv中的第316行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/management/init.py”,在执行的第375行 文件“ /home/myUser/.local/share/virtualenvs/myVirtualEnv-vCGrYWCJ/lib/python3.5/site-packages/django/core/management/init.py”,execute_from_command_line中的第381行 文件“ manage.py”,位于第15行 分割错误
我正在运行openSuse Linux,python 3.5.4和Django 2.1.5,并将SQL Server作为数据库。这是我在环境中拥有的模块:
atomicwrites 1.2.1
袭击18.2.0
Django 2.1.5
django-cors-headers 2.4.0
django-multiselectfield 0.1.8
django-pyodbc-azure 2.1.0.0
djangorestframework 3.9.1
djangorestframework-jwt 1.11.0
gunicorn 19.9.0
more-itertools 5.0.0
pathlib2 2.3.3
枕头5.4.1
点19.0.1
塞子0.8.1
psycopg2 2.7.7
py 1.7.0
PyJWT 1.7.1
pyodbc 4.0.25
pytest 4.1.1
pytz 2018.9
reportlab 3.5.13
setuptools 40.6.3
六个1.12.0
轮0.32.3
XlsxWriter 1.1.2
我尝试删除并重新安装Pipenv环境,但是它仍然引发此分段错误。我可以在例程中查询模型,该例程可以从Django交互式外壳程序中不断抛出分段错误,而不会抛出seg错误。真的很奇怪。