pythondjangouwsgispooler

uwsgi unable to find the spooler function


I was trying to find out about the spooler mechanism of uWSGI and for that reason I've written a small, dummy web application with Django (version 1.3.1) and it is running on the latest stable version of nginx. Everything works as expected. However, in one of my views, I am sending a spool message to the uWSGI container and, I get the following error:

[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 ?

In my testapp/views.py file:

from django.http import HttpResponse
from testapp.spool import three_seconds

def call(request):
    three_seconds.spool(a=1, b=2)
    return HttpResponse('spooled')

In my testapp/spool.py file:

from uwsgidecorators import *

@spool
def three_seconds(*args, **kwargs):
    f = open('/tmp/args.data', 'a')
    f.write(repr(kwargs) + '\n')
    f.close()

When I've executed the function 'call' by requesting the url /call/ in the browser, I got the following error:

[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 is running with the following parameters:

sudo uwsgi --ini ~/uwsgi.ini -b 20000

And the content of my uwsgi.ini file looks like follows:

[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

I have no clue why it's been complaining about the spooler function and why uwsgi could not find it. And what does "have you loaded it into the spooler process" mean? How can one load a spooler function in the spooler process's context?


Solution

  • use spooler-import = testapp/spool.py

    The spooler process will import that module in its process address space

    another solution is importing the module in all of the uwsgi processes with

    import = testapp/spool.py