-
Notifications
You must be signed in to change notification settings - Fork 179
Open
Description
When calling TcpWSGIServer.close() on Unix-like systems (macOS and Ubuntu tested), the program sometimes crashes with OSError: [Errno 9] Bad file descriptor.
Reproducible sample (might have to run multiple times to replicate):
from __future__ import annotations
from time import sleep
from flask import Flask, make_response
from threading import Thread
from waitress.server import TcpWSGIServer
app = Flask("TestApp")
@app.route("/")
def get():
return make_response("test!")
server = TcpWSGIServer(app, host="0.0.0.0", port="24839")
worker_thread = Thread(target=server.run)
worker_thread.start()
print("Started server.")
sleep(2)
server.close()
worker_thread.join()
print("Killed server.")
Traceback:
.../.venv/bin/python .../playground/waitress_bug.py
Started server.
Exception in thread Thread-1 (run):
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File ".../.venv/lib/python3.12/site-packages/waitress/server.py", line 325, in run
self.asyncore.loop(
File ".../.venv/lib/python3.12/site-packages/waitress/wasyncore.py", line 240, in loop
poll_fun(timeout, map)
File ".../.venv/lib/python3.12/site-packages/waitress/wasyncore.py", line 167, in poll
r, w, e = select.select(r, w, e, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 9] Bad file descriptor
Killed server.
Process finished with exit code 0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels