werkzeug icon indicating copy to clipboard operation
werkzeug copied to clipboard

[Win32] AttributeError: 'module' object has no attribute 'SIGKILL'

Open ricard33 opened this issue 15 years ago • 3 comments

Since change id "de19b674" from mitsuhiko (on 2011-07-05 "Added an ugly way to shutdown the Werkzeug server"), this error is displayed on each request using Werkzeug deguger on Django (django + django_extensions + werkzeug).

Full traceback :


Exception happened during processing of request from ('127.0.0.1', 49331) Traceback (most recent call last): File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock self.process_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 310, in process_request self.finish_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 323, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python27\lib\SocketServer.py", line 639, in init self.handle() File "C:\Python27\lib\site-packages\werkzeug\serving.py", line 188, in handle self.initiate_shutdown() File "C:\Python27\lib\site-packages\werkzeug\serving.py", line 197, in initiate_shutdown os.kill(os.getpid(), signal.SIGKILL)

AttributeError: 'module' object has no attribute 'SIGKILL'

ricard33 avatar Oct 31 '11 14:10 ricard33

Welcome to the wonderful world of the ugliness that is the Python interpreter shutdown. I don't think there is much I can do here besides pulling in the SIGKILL constant earlier. The real culprit is that the Python interpreter shutdown changes slightly over time and generally stuff that executes late as part of the shutdown process has to live with various limitations.

Any idea if I can reliably reproduce this?

mitsuhiko avatar Oct 31 '11 14:10 mitsuhiko

I haven't looked at the code, but if I'm reading ricard33's post right. I think the issue is that the signal module he's using on Win32 does not contain the SIGKILL constant. The Python signal module documentation states that not all signal constants are supported by all OSs and are not included in the module for that OS if not supported.

I did a little web search and it appears that the lack of SIGKILL support might be the case for Win32 in general and not just an issue of an older version of the signal module.

That said, my understanding of the nature of signal handling on Win32 is that they all terminate unconditionally. I.e. a SIGTERM on Win32 is equivalent to a SIGKILL on Linux.

A change to raise the SIGTERM if SIGKILL is not defined might be sufficient to resolve this issue. At least until a "pretty" way of shutting down the server is created.

sergedomk avatar Nov 01 '11 14:11 sergedomk

Oh indeed. In suspected something else there. Let me check that.

mitsuhiko avatar Nov 01 '11 15:11 mitsuhiko