title: ValueError: signal only works in main thread - Django - mod_wsgi
body: <p>I am trying to execute a shell command and kill it using python <strong>signal</strong> module.</p>
  
  <p>I know signals work only with main thread, so I run the Django development server with,</p>
  
  <pre><code>python manage.py runserver --nothreading --noreload
  </code></pre>
  
  <p>and it works fine.</p>
  
  <p>But when i deploy the django application with Apache/mod_wsgi, it shows the following error:</p>
  
  <pre><code>[Fri Sep 12 20:07:00 2014] [error]     response = function.call(request, **data)
  [Fri Sep 12 20:07:00 2014] [error]   File "/Site/cloud/lib/python2.6/site-packages/dajaxice/core/Dajaxice.py", line 18, in call
  [Fri Sep 12 20:07:00 2014] [error]     return self.function(*args, **kwargs)
  [Fri Sep 12 20:07:00 2014] [error]   File "/Site/cloud/soc/website/ajax.py", line 83, in execute
  [Fri Sep 12 20:07:00 2014] [error]     data = scilab_run(code, token, book_id, dependency_exists)
  [Fri Sep 12 20:07:00 2014] [error]   File "/Site/cloud/soc/website/helpers.py", line 58, in scilab_run
  [Fri Sep 12 20:07:00 2014] [error]     output = task.run().communicate()[0]
  [Fri Sep 12 20:07:00 2014] [error]   File "/Site/cloud/soc/website/timeout.py", line 121, in run
  [Fri Sep 12 20:07:00 2014] [error]     lambda sig,frame : os.killpg(self.pgid,self.timeoutSignal) )
  [Fri Sep 12 20:07:00 2014] [error] ValueError: signal only works in main thread
  </code></pre>
  
  <p>Here is my apache virtualhost setting:</p>
  
  <pre><code>WSGIDaemonProcess testcloud display-name=scilab_cloud  user=apache group=apache threads=1
  WSGIProcessGroup testcloud
  WSGIScriptAlias / /Site/cloud/soc/soc/wsgi.py
  WSGIImportScript /Site/cloud/soc/soc/wsgi.py process-group=testcloud application-group=%{GLOBAL}
  </code></pre>
  
  <p>I also have the below settings outside virtualhost in httpd.conf:</p>
  
  <pre><code>WSGIRestrictSignal Off
  WSGISocketPrefix /var/run/wsgi
  </code></pre>
  
  <p><a href="https://gist.github.com/devietti/1526975" rel="noreferrer">Here is the link</a> to the program which uses <strong>signal</strong> and the one which I use in my django application.</p>
  
  <p>Any help would be appreciated.  </p>