AttributeError: module 'signal' has no attribute 'SIGHUP'
I am trying to integrate mod_wsgi into my django project on Windows 10. While I was able to install mod_wsgi into my virtual environment, I am running into errors while trying the command python manage.py runmodwsgi.
(venv) PS D:\Tutorials\Python\Projects\ADSS> python manage.py runmodwsgi
Successfully ran command.
Server URL : http://localhost:8000/
Server Root : C:/Users/admin/AppData/Local/Temp/mod_wsgi-localhost-8000-admin
Server Conf : C:/Users/admin/AppData/Local/Temp/mod_wsgi-localhost-8000-admin/httpd.conf
Error Log File : C:/Users/admin/AppData/Local/Temp/mod_wsgi-localhost-8000-admin/error_log (warn)
Operating Mode : daemon
Request Capacity : 5 (1 process * 5 threads)
Request Timeout : 60 (seconds)
Startup Timeout : 15 (seconds)
Queue Backlog : 100 (connections)
Queue Timeout : 45 (seconds)
Server Capacity : 20 (event/worker), 20 (prefork)
Server Backlog : 500 (connections)
Locale Setting : en_US.cp1252
Traceback (most recent call last):
File "D:\Tutorials\Python\Projects\ADSS\manage.py", line 25, in <module>
execute_from_command_line(sys.argv)
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\django\core\management\base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\django\core\management\base.py", line 448, in execute
output = self.handle(*args, **options)
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\mod_wsgi\server\management\commands\runmodwsgi.py", line 162, in handle
signal.signal(signal.SIGHUP, handler)
AttributeError: module 'signal' has no attribute 'SIGHUP'
Google seems to suggest that signal.SIGHUP, signal.SIGUSR1 and signal.SIGWINCH as being used by my mod_wsgi installation aren't supported on Windows. So I tried the following two methods in .\venv\Lib\site-packages\mod_wsgi\server\management\commands\runmodwsgi.py:
- I tried using the if-condition
if platform.system() != 'Linux':as suggested on this Q&A, - I also tried commenting out the lines making use of these signals in this file.
In either case, I kept running across some or the other error, making me wonder if my installation of mod_wsgi is correct at all.
I have been following the instructions as written on mod_wsgi's PyPi listing. I am writing them here for reference:
- Obtained a copy of Apache 2.4.54 Win64 from https://www.apachelounge.com/download/
- Extracted this zip file and placed the Apache24 folder in my C: as
C:\Apache24. - Set
Define SRVROOT "c:/Apache24"andListen 8000inhttpd.conf. Verified that things work and the default homepage is loaded (http://localhost:8000). - Installed Visual Studio C++ build tools using Visual Studio Installer (the 'Desktop development with C++' category).

- Installed mod_wsgi into my virtual environment by running the command
pip install mod-wsgiin my active virtual environment in anx64 Native Tools Command Prompt for VC2022window. - Added
'mod_wsgi.server',to the list ofINSTALLED_APPSin mysettings.py. - Ran
python manage.py collectstatic - Ran
mod_wsgi-express module-configwhich output the following three lines, which I placed at the end of myhttpd.conf:
LoadFile "C:/Program Files/Python310/python310.dll"
LoadModule wsgi_module "D:/Tutorials/Python/Projects/ADSS/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp310-win_amd64.pyd"
WSGIPythonHome "D:/Tutorials/Python/Projects/ADSS/venv"
- Ran
python manage.py runmodwsgi, which is resulting in the error log I mentioned at the start of my post.
Please throw light on what I might be doing incorrectly.
I also have Visual Studio installed, which I am using for this project.
I changed from port 80 to port 8000 in httpd.conf because my IIS doesn't allow Apache to run on port 80.
Sorry for the delay, been overseas on a trip.
On Windows you should do (8) in your list but not (9). That is, don't try and use mod_wsgi-express directly or via Django management command. The mod_wsgi-express functionality is completely experimental and never worked properly on Windows and no one has ever offered to help get it working. It also seems that some changes which where made for Unix systems means it doesn't even run on Windows anymore. That latter issue could be fixed, but not really worth it due to the other issues it had on Windows and no one being willing to help get it working.
So once you do (8), manually configure your Apache installation for hosting your WSGI application and start/stop the Apache service as you would normally.
Hi! Thanks for the answer, Graham! For others, what Graham is saying is demonstrated in Johnnyboycurtis's video here. I also created (and answered) a StackOverflow Q&A to this effect.