运行Django的这两种配置有什么不同?

2024-05-14 13:39:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这两种配置。我要知道有什么区别,哪种更好更快?你知道吗

第一形态:

#!/home/user/bin/python
import sys, os
sys.path.insert(0,"/home/user/projects/")
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'

from flup.server.fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
WSGIServer(WSGIHandler()).run()

第二形态:

#!/home/user/bin/python
import sys, os
sys.path.insert(0,"/home/user/projects/")
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

谢谢:D

更新:

I did a quick test with python cProfile lib。在doc中,WSGI对应于第一个conf,FCGI对应于第二个conf


Tags: pathdjangofromimporthomebinsettingsos
1条回答
网友
1楼 · 发布于 2024-05-14 13:39:47

Django本机使用WSGI,因此通过FastCGI运行它为HTTP消息添加了另一层。话虽如此,如果您可以选择快速的FastCGI容器还是慢速的WSGI容器,那么使用额外的层可能会更好。你知道吗

相关问题 更多 >

    热门问题