-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
random failures when running test_conn with Python 3.13 #734
Comments
Thanks for reporting! Sounds like pytest's warning tracking feature detects an exception that was being ignored silently in older CPython releases. A short-term workaround for the tests could be adding an ignore entry to |
I tried adding Adding |
Yeah, it sounds like there's a race condition somewhere. If you send a PR with that but a more granular ignore matching the specific message, I'm open to accepting it as an immediate workaround. |
Let's keep this open until the real fix can be implemented. |
For what it's worth, this isn't only an issue in cheroot's tests - I have a test HTTP server I run as a subprocess for qutebrowser tests, and I see this pop up there as well. I think a prerequisite to trigger it is that the client aborts the connection, I've been able to reproduce it when spamming F5 in a browser (which seems to have cancelled requests for e.g. However, setting a requests timeout seems to reproduce it nicely, here is what I use to get it happen within 0.5s or so: import time
import requests
import requests.exceptions
import threading
from cheroot import wsgi
def timeout_app(environ, start_response):
time.sleep(0.05)
status = '200 OK'
headers = [('Content-type', 'text/plain; charset=utf-8')]
start_response(status, headers)
return [b""]
port = 1234
server = wsgi.Server(('localhost', port), timeout_app)
url = f"http://localhost:{port}"
print(url)
thread = threading.Thread(target=server.safe_start)
thread.start()
while not server.ready:
time.sleep(0.1)
while True:
try:
requests.get(url, timeout=0.01)
except requests.exceptions.ReadTimeout:
print("!", end="", flush=True)
else:
print(".", end="", flush=True) |
Here is a workaround that works outside of pytest and hides those warnings: import sys
import errno
def unraisable_hook(unraisable: "sys.UnraisableHookArgs") -> None:
if (
sys.version_info[:2] == (3, 13)
and isinstance(unraisable.exc_value, OSError)
and (
unraisable.exc_value.errno == errno.EBADF
or (
sys.platform == "win32"
and unraisable.exc_value.winerror == errno.WSAENOTSOCK
)
)
and unraisable.object.__qualname__ == "IOBase.__del__"
):
# WORKAROUND for bogus exceptions with cheroot:
# https://github.com/cherrypy/cheroot/issues/734
return
sys.__unraisablehook__(unraisable)
sys.unraisablehook = unraisable_hook |
β I'm submitting a ...
π Describe the bug. What is the current behavior?
And one more failure with Python 3.13: when running
cheroot/test/test_conn.py
, I am seeing one of the tests fail with the following error:I saw the following three fail:
test_streaming_10[True]
,test_keepalive[HTTP/1.0]
,test_keepalive[HTTP/1.1]
with this error, although it's always just one for each run (and it seems random).This again seems to be related to the following io change:
https://docs.python.org/3/whatsnew/3.13.html#io
I wasn't able to find a fix for this one.
π‘ To Reproduce
Run the test suite with Python 3.13.0.
π Details
Full traceback:
π Environment
The text was updated successfully, but these errors were encountered: