title: UWSGI timer and cron decorators running duplicate jobs
body: <p>I have been trying to make the uwsgi python spooler work properly for quite some time. I have a setup in which I run a django application with two worker processes. I have tried setting a cron spooler (and a timer spooler) to run a task every ten minutes, but no matter what configuration of settings I've tried, it always seems to register the signal multiple times, and running the task multiple times.</p>
  
  <p>This is how I run uwsgi:</p>
  
  <pre><code>#!/bin/bash
  sudo uwsgi --emperor /etc/uwsgi/vassals --uid http --gid http --enable-threads --pidfile=/tmp/uwsgi.pid --daemonize=/var/log/uwsgi/uwsgi.log
  </code></pre>
  
  <p>This is my uwsgi vassal config in /etc/uwsgi/vassals/django.ini:</p>
  
  <pre><code>[uwsgi]
  
  chdir           = /home/user/django
  module          = django.wsgi
  
  master          = true
  processes       = 2
  socket          = /tmp/uwsgi-django.sock
  vacuum          = true
  pidfile         = /tmp/uwsgi-django.pid
  daemonize      = /home/user/django/log.log
  env = DJANGO_SETTINGS_MODULE=django.settings
  #lazy-apps = false
  #lazy = false
  spooler = %(chdir)/tasks
  #spooler-processes = 1
  #import = django-app/spooler.py
  #spooler-import = django-app/spooler.py
  shared-import = django-app/spooler.py
  </code></pre>
  
  <p>(I have changed some of the path names for privacy reasons). The lines that are commented out are various attempts at making it not duplicate my signals, but every time it seems to register the signal twice, and sometimes even thrice (presumably in both the workers and the single spooler process).</p>
  
  <pre><code>[uwsgi-signal] signum 0 registered (wid: 0 modifier1: 0 target: default, any worker)
  [uwsgi-signal] signum 1 registered (wid: 1 modifier1: 0 target: default, any worker)
  [uwsgi-signal] signum 1 registered (wid: 2 modifier1: 0 target: default, any worker)
  </code></pre>
  
  <p>Does anyone know why this is happening, and how to properly prevent it?</p>
  
  <p>This is the spooler.py file:</p>
  
  <pre><code>@cron(-10, -1, -1, -1, -1)
  def periodicUpdate(signal):
      print "Running cron job..."
      _getStats()
  </code></pre>
  
  <p>also tried</p>
  
  <pre><code>@timer(600)
  def periodicUpdate(signal):
      print "Running cron job..."
      _getStats()
  </code></pre>
  
  <p>I also tried adding <code>target='spooler'</code> to the timer/cron-decorator, but it did not seem to many any difference.</p>