unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.46k stars 691 forks source link

[uwsgi 2.0.12] Spool func is not found and a KeyError is raised #1242

Open btall opened 8 years ago

btall commented 8 years ago

An spoolraw function defined in the same file that the mule and called from a mules process, product a KeyError when the spool file is loaded.

_But this phenomenon is only present occasionally ! For avoid this, I must touch the ini file x times for reloaded and make it functional._

Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/uwsgidecorators.py", line 54, in manage_spool_request  
f = spooler_functions[vars['ud_spool_func']]
KeyError
: 
'my_spooler'

I've the feeling that the mules try to spool the tasks before than the uwsgi spool functions are registered

_config.ini_

[uwsgi]
plugins = python27
socket = /run/uwsgi/%n.socket
master = true
enable-threads = true

chdir = /tmp

py-call-osafterfork = true
for-times = 4
    mule = file.py
end-for =

spooler-processes = 4
spooler = /tmp/uwsgi/spool/test
spooler-quiet = true
spooler-import = file.py

_file.py_

# vim: set fileencoding=utf-8 ft=python sw=4 ts=4 et ai:
import uwsgi
from time import sleep
from uwsgidecorators import spoolraw

@spoolraw
def my_spooler(env):
    try:
        print u"spooler_task_name={spooler_task_name} ud_spool_func={ud_spool_func}".format(**env)
    except:
        print 'Failed ! spooler_task_name={spooler_task_name} :-('.format(**env)
        return uwsgi.SPOOL_RETRY
    else:
        print 'Success ! msg={msg} \\o/'.format(**env)
        return uwsgi.SPOOL_OK

if not uwsgi.i_am_the_spooler():
    i = 1
    while True:
        my_spooler.spool(msg=u'Task {}'.format(i))
        i += 1
        sleep(1)
Lagovas commented 7 years ago

the same with

$ uwsgi --version
2.0.7-debian