Python Django奇怪的行为:无限加载所有视图,但Django正在工作

Python Django奇怪的行为:无限加载所有视图,但Django正在工作,python,django,mod-wsgi,Python,Django,Mod Wsgi,在Django(1.8.12,Ubuntu14.04)有2年的工作经验,第一次面对这个问题 过了一段时间(不知道为什么),我来到我的网站并尝试加载一些页面:结果是无限加载所有视图,包括管理面板(无法登录)和所有外部视图。“浏览器”选项卡显示“加载循环”和“从不加载” 超级奇怪的是:我尝试从settings.py添加\删除一些应用程序,在代码中出错,添加\删除一些导入,当我这样做时,Django开始正常工作:它显示我的标准错误页面(带回溯的黄灰色)。然后我去编码并修复错误——无限加载再次出现 今天

在Django(1.8.12,Ubuntu14.04)有2年的工作经验,第一次面对这个问题

过了一段时间(不知道为什么),我来到我的网站并尝试加载一些页面:结果是无限加载所有视图,包括管理面板(无法登录)和所有外部视图。“浏览器”选项卡显示“加载循环”和“从不加载”

超级奇怪的是:我尝试从settings.py添加\删除一些应用程序,在代码中出错,添加\删除一些导入,当我这样做时,Django开始正常工作:它显示我的标准错误页面(带回溯的黄灰色)。然后我去编码并修复错误——无限加载再次出现

今天有一次,我能够让我的视图正常工作——它被正常加载(带表单的简单视图)。但是第二次重新加载这个视图是不可能的——它加载了一次,之后我在所有其他尝试中再次得到无限加载

在Apache error.log中,我看到:

我尝试的:删除.pyc文件,mod_wsgi更新。Django migrate正在运行。

解决方案正在运行

我已经将
WSGIApplicationGroup%{GLOBAL}
添加到apache配置中。
仍然不确定为什么会出现此问题

您是否已重新启动apache?发生了什么事?@SancaKembang是的,多次重启apache,没有什么好的)现在您的服务器中有多少个项目?你用一个apache和多个python版本试过吗?@SancaKembang-只有一个项目,没有试过,仅使用python 3.4在mod_wsgi的文档中提到,您使用的python包使用C扩展,在python子解释器中无法正常工作。@GrahamDumpleton-也许您是对的:我猜这是在安装机器学习包TensorFlow、Keras、Theano之后开始的。但当我移除它们时,问题并没有消失。“正确地使用Python子解释器”是什么意思?在生产中,我只使用Python 3.4。Ubuntu也有2.7版本,但我没有在那里安装任何新的东西。这是Python的一个特性,在一个进程中,您可以创建多个解释器空间,每个解释器空间都应该单独运行。在mod_wsgi中,它使用这些来将不同的wsgi应用程序彼此分离。有些模块,例如
numpy
不使用pythonc库中的特定线程api,这将允许它们在这些子解释器中工作。该指令强制所有内容在进程的主解释器上下文中运行,这与使用命令行Python时发生的情况相同。使用的简化Python线程API将可以工作。非常感谢!我花了几个小时在Apache服务器上运行的Python应用程序中寻找无限加载的解决方案。
    [Tue Feb 07 19:50:23.776657 2017] [core:warn] [pid 16963:tid 139669519046528] AH00045: child process 16966 still did not exit, sending a SIGTERM
[Tue Feb 07 19:50:23.776852 2017] [core:warn] [pid 16963:tid 139669519046528] AH00045: child process 16967 still did not exit, sending a SIGTERM
[Tue Feb 07 19:50:25.779159 2017] [core:warn] [pid 16963:tid 139669519046528] AH00045: child process 16966 still did not exit, sending a SIGTERM
[Tue Feb 07 19:50:25.779280 2017] [core:warn] [pid 16963:tid 139669519046528] AH00045: child process 16967 still did not exit, sending a SIGTERM
[Tue Feb 07 19:50:27.781572 2017] [core:warn] [pid 16963:tid 139669519046528] AH00045: child process 16966 still did not exit, sending a SIGTERM
[Tue Feb 07 19:50:27.781704 2017] [core:warn] [pid 16963:tid 139669519046528] AH00045: child process 16967 still did not exit, sending a SIGTERM
[Tue Feb 07 19:50:29.784028 2017] [core:error] [pid 16963:tid 139669519046528] AH00046: child process 16966 still did not exit, sending a SIGKILL
[Tue Feb 07 19:50:29.784174 2017] [core:error] [pid 16963:tid 139669519046528] AH00046: child process 16967 still did not exit, sending a SIGKILL
[Tue Feb 07 19:50:30.785515 2017] [mpm_event:notice] [pid 16963:tid 139669519046528] AH00491: caught SIGTERM, shutting down
[Tue Feb 07 19:50:31.628188 2017] [ssl:warn] [pid 17265:tid 140333802358656] AH01909: RSA certificate configured for 10.1.1.163:443 does NOT include an ID which matches the server name
[Tue Feb 07 19:50:31.649372 2017] [ssl:warn] [pid 17266:tid 140333802358656] AH01909: RSA certificate configured for 10.1.1.163:443 does NOT include an ID which matches the server name
[Tue Feb 07 19:50:31.649851 2017] [:warn] [pid 17266:tid 140333802358656] mod_wsgi: Compiled for Python/3.4.0.
[Tue Feb 07 19:50:31.649872 2017] [:warn] [pid 17266:tid 140333802358656] mod_wsgi: Runtime using Python/3.4.3.
[Tue Feb 07 19:50:31.651402 2017] [mpm_event:notice] [pid 17266:tid 140333802358656] AH00489: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f mod_wsgi/3.4 Python/3.4.3 configured -- resuming normal operations
[Tue Feb 07 19:50:31.651466 2017] [core:notice] [pid 17266:tid 140333802358656] AH00094: Command line: '/usr/sbin/apache2'
[Tue Feb 07 19:50:33.728378 2017] [:error] [pid 17270:tid 140333668648704] /usr/lib/python3.4/importlib/_bootstrap.py:321: RemovedInDjango19Warning: The django.forms.util module has been renamed. Use django.forms.utils instead.
[Tue Feb 07 19:50:33.728432 2017] [:error] [pid 17270:tid 140333668648704]   return f(*args, **kwds)