我试图了解uWSGI的假脱机机制,因此我用Django(版本 1.3.1)编写了一个小的虚拟 Web 应用程序,它运行在最新的稳定版本nginx上。一切都按预期工作。但是,在我的一个观点中,我正在向 uWSGI 容器发送假脱机消息,并且收到以下错误:
[spooler /private/tmp/receiver pid: 4115] managing request uwsgi_spoolfile_on_ozgurv.local_4165_1_0_1338280641_366596 ...
unable to find the spooler function, have you loaded it into the spooler process ?
在我的 testapp/views.py 文件中:
from django.http import HttpResponse
from testapp.spool import three_seconds
def call(request):
three_seconds.spool(a=1, b=2)
return HttpResponse('spooled')
在我的 testapp/spool.py 文件中:
from uwsgidecorators import *
@spool
def three_seconds(*args, **kwargs):
f = open('/tmp/args.data', 'a')
f.write(repr(kwargs) + '\n')
f.close()
当我通过在浏览器中请求 url /call/ 执行函数“调用”时,出现以下错误:
[spooler /private/tmp/receiver pid: 4115] managing request uwsgi_spoolfile_on_ozgurv.local_4165_1_0_1338280641_366596 ...
unable to find the spooler function, have you loaded it into the spooler process ?
uWSGI 使用以下参数运行:
sudo uwsgi --ini ~/uwsgi.ini -b 20000
我的 uwsgi.ini 文件的内容如下所示:
[uwsgi]
socket = 127.0.0.1:8081
listen = 4096
master = true
processes = 4
pidfile = /var/run/uwsgi.pid
enable-threads = true
uid=root
gid=admin
single-interpreter = true
disable-logging = true
buffer-size= 32768
reload-on-as = 10240
reload-on-rss = 512i0
max-requests = 50000
pythonpath = /Users/ozgurv/Developer/warehouse
module = wsgi_handler
plugins = python27,spooler
spooler-processes = 1
spooler = /tmp/receiver
我不知道为什么它一直在抱怨后台处理程序功能以及为什么uwsgi找不到它。“您已将其加载到后台处理程序进程中”是什么意思?如何在 spooler 进程的上下文中加载一个 spooler 函数?