web2py / py4web

Other
253 stars 128 forks source link

signal.SIGKILL isn't available on Windows #931

Open laundmo opened 2 days ago

laundmo commented 2 days ago

The line https://github.com/web2py/py4web/blob/48445773149c6ef1cf03dfa301d68f04ee55d918/py4web/core.py#L1721-L1722 added by

causes the following error when running on Windows and hitting CTRL+C, as signal.SIGKILL isn't available on Windows:

Traceback (most recent call last):
  File "[REDACTED]\.venv\lib\site-packages\rocket3\__init__.py", line 666, in start
    time.sleep(THREAD_STOP_CHECK_INTERVAL)
  File "[REDACTED]\.venv\lib\site-packages\py4web\core.py", line 1722, in kill_all
    os.kill(os.getpid(), signal.SIGKILL)
AttributeError: module 'signal' has no attribute 'SIGKILL'
 > MainThread > 14:19:04.192

This error results in being unable to stop py4web using CTRL+C as it just keeps running.

See: https://discuss.python.org/t/terminateprocess-via-os-kill-on-windows/30882 for details on os.kill on windows - it seems it would be best not to use it if at all possible.

laundmo commented 2 days ago

Seems like this may be a good solution https://stackoverflow.com/a/70565806