我通过GitHub将本地开发的Django web应用程序部署到azure中,当我尝试运行URL时,在web.config文件中得到以下错误
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\home\python364x64\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\home\python364x64\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "D:\home\python364x64\wfastcgi.py", line 605, in get_wsgi_handler
handler = handler()
File ".\ptvs_virtualenv_proxy.py", line 107, in get_venv_handler
handler = get_wsgi_handler(os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
File ".\ptvs_virtualenv_proxy.py", line 65, in get_wsgi_handler
handler = handler()
File "D:\home\site\wwwroot\env\lib\site-packages\django\core\wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "D:\home\site\wwwroot\env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\home\site\wwwroot\env\lib\site-packages\django\apps\registry.py", line 81, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
StdOut:
StdErr:这是我的web.config文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off" />
</system.web>
<appSettings>
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS" value="D:\home\site\wwwroot\env\Scripts\python.exe" />
<add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_venv_handler()" />
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
<add key="DJANGO_SETTINGS_MODULE" value="FinTech.settings" />
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
<system.webServer>
<httpErrors errorMode="Detailed" />
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python364x64\python.exe|D:\home\python364x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
<rewrite>
<rules>
<rule name="Static Files" stopProcessing="true">
<conditions>
<add input="true" pattern="false" />
</conditions>
</rule>
<rule name="Configure Python" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
</conditions>
<action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>我的代码有问题吗?或者我需要安装一些额外的需求吗?我在Azure中尝试运行django web应用程序时遇到此错误,当我在本地运行web应用程序时,它工作正常。
发布于 2018-07-19 11:10:49
填充:
()不是可重入的
我将我的django应用程序部署到azure,但没有重现您的问题。据我所知,这意味着其中一个配置不正确或缺少所需的库将引发此填充错误。
我建议你将下面的代码添加到你的wsgi.py文件中,并且真正的错误应该被记录下来,然后你可以检查它。
import os
import time
import traceback
import signal
import sys
from django.core.wsgi import get_wsgi_application
try:
application = get_wsgi_application()
print 'WSGI without exception'
except Exception:
print 'handling WSGI exception'
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)更多解决方案,请参考以下主题:
1.Django populate() isn't reentrant
2.Django stops working with RuntimeError: populate() isn't reentrant
希望能对你有所帮助。
https://stackoverflow.com/questions/51410838
复制相似问题