Need to KeyboardInterrupt 3 times to stop the server
See original GitHub issueโ Iโm submitting a โฆ
- ๐ bug report
- ๐ฃ feature request
- โ question about the decisions made in the repository
๐ Describe the bug. What is the current behavior?
I am trying out cheroot for the first time today. When I run my flask application with cheroot, I find that to stop the application, I need to hit Ctrl+C
3 times - even if I wait for nearly 2-3 minutes and no requests are being processed.
โ What is the motivation / use case for changing the behavior? It intuitively stop if I hit the Ctrl+C once I think ?
๐ก To Reproduce
$ mkdir -p /tmp/cheroottesting
$ cd /tmp/cheroottesting
$ python -m venv venv
$ venv/bin/pip install cheroot
$ cat app.py
from wsgiref.simple_server import make_server
def application(environ, start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return [b"Hello World !"]
$ export PYTHONPATH=.
$ venv/bin/cheroot app:application -b 0.0.0.0:5000
What I observe:
Note: I have tried to wait for about 30sec after hitting Ctrl-C for it to complete cleaning up after itself, didnt help much
๐ก Expected behavior The server should have stopped after I hit the first Ctrl-C
๐ Details
$ venv/bin/cheroot app:application --bind 0.0.0.0:5000
^CKeyboard Interrupt: shutting down
^CTraceback (most recent call last):
File "/tmp/cheroottesting/venv/lib/python3.7/site-packages/cheroot/server.py", line 1710, in safe_start
self.start()
File "/tmp/cheroottesting/venv/lib/python3.7/site-packages/cheroot/server.py", line 1819, in start
self.serve()
File "/tmp/cheroottesting/venv/lib/python3.7/site-packages/cheroot/server.py", line 1798, in serve
self.tick()
File "/tmp/cheroottesting/venv/lib/python3.7/site-packages/cheroot/server.py", line 2038, in tick
conn = self._connections.get_conn()
File "/tmp/cheroottesting/venv/lib/python3.7/site-packages/cheroot/connections.py", line 137, in get_conn
in self._selector.select(timeout=0.01)
File "/home/abdealijk/miniconda3/lib/python3.7/selectors.py", line 468, in select
fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "venv/bin/cheroot", line 10, in <module>
sys.exit(main())
File "/tmp/cheroottesting/venv/lib/python3.7/site-packages/cheroot/cli.py", line 241, in main
raw_args._wsgi_app.server(raw_args).safe_start()
File "/tmp/cheroottesting/venv/lib/python3.7/site-packages/cheroot/server.py", line 1715, in safe_start
self.stop()
File "/tmp/cheroottesting/venv/lib/python3.7/site-packages/cheroot/server.py", line 2071, in stop
time.sleep(0.1)
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/home/abdealijk/miniconda3/lib/python3.7/threading.py'>
Traceback (most recent call last):
File "/home/abdealijk/miniconda3/lib/python3.7/threading.py", line 1307, in _shutdown
lock.acquire()
KeyboardInterrupt
๐ Environment
- Cheroot version: 8.4.5
- CherryPy version: Not using it
- Python version: 3.7.7
- OS: Windows 10 + Ubuntu 18.04.4 LTS in WSL2
- Browser: Not applicable
๐ Additional context Maybe this is related to: https://github.com/cherrypy/cheroot/issues/323
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
FWIW this also seems to affect SIGTERM, which causes the server to not exit at all (even when doing it multiple times).
@loqs Iโm pretty sure the CherryPy test is flaky regardless. Thatโs why itโs important to have a good test here too.