uwsgi无法找到假脱机程序功能

时间:2012-05-29 09:24:42

标签: python django uwsgi spooler

我试图了解spooler mechanismuWSGI,因此我编写了一个带有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 /执行函数'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无法找到它。什么“你把它加载到假脱机程序中”是什么意思?如何在假脱机程序进程的上下文中加载假脱机程序函数?

1 个答案:

答案 0 :(得分:2)

使用spooler-import = testapp / spool.py

假脱机程序进程将在其进程地址空间中导入该模块

另一个解决方案是使用

导入所有uwsgi进程中的模块

import = testapp / spool.py