-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
tests - add test for ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object … #5146
base: master
Are you sure you want to change the base?
Conversation
@commonism Git setup on your computer looks broken: none of the submitted commits list your GitHub account as an author. You should probably configure Git locally or verify the email that is embedded in those commits in your GitHub account. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the effort! Unfortunately, this doesn't look ready, nor is compliant with our test writing practices.
Also, there's great prior art on the usage of pytest fixtures including proper TLS setup — https://github.com/aio-libs/aiohttp/pull/4713/files — why haven't you start there? It also uses proper loop isolation, and pytest-based warnings tracking.
Besides, adding a custom server/client implementations doesn't seem related to the problem you're attempting to reproduce — it only makes the test module messy and distracts from what's actually being tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@commonism I respect your striving to point on the very annoying issue.
It will be never fixed on aiohttp 3.x branch, sorry.
aiohttp 4.0 has partially done work for getting rid of the warning. The missing part is #5102
P.S.
aiohttp uses pytest
with pytest-aiohttp
plugin, not the standard unittest
.
This is the deliberate choice. We don't accept tests that are unittest
based.
P.P.S.
I'm aware of unittest.IsolatedAsyncioTestCase
because I had added it to the CPython standard library.
It exists because CPython itself cannot depend on pytest
project for running self-testing.
For third-party libs I always prefer pytest-style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I addressed the following issues
- pytest, not a unittest
- no logging/print
- no tracemalloc
- reduce time required to 5s (was 30 seconds actually)
- using the internal trustme CA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressing the issues.
@commonism we also need the CI to actually execute this test. Red linting job prevents that from happening. |
@commonism P.S. your local Git setup is still broken |
The Red Linter is gone, now the tests fail after 2 minutes - timeout? |
common seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
2709007
to
d305f77
Compare
Actually the timer got canceld?
https://github.com/aio-libs/aiohttp/actions/runs/5978392347/job/16220898181 |
Hmm, we switched to asyncio.timeout() recently. So, I've merged master and will see if that helps. |
# this is expected and not a failure. | ||
pass | ||
finally: | ||
await asyncio.sleep(0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's the 300s ClientTimeout
real_timeout = ClientTimeout(total=300, connect=None, sock_read=None, sock_connect=None, ceil_threshold=5)
300.26s call tests/test_ssl_transport_close.py::test_unclosed_transport_asyncio_sslproto_SSLProtocolTransport[pyloop]
increasing the sleep to something larger to have to server restart in time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing how the sleep relates to it, but we can try it if you think that's the problem.
await dq.get() | ||
dq.task_done() | ||
site = next(iter(runner.sites)) | ||
await site.stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 3.12 it hangs here - you do not get
DEBUG aiohttp.server:web_protocol.py:434 Ignored premature client disconnection
as you get in 3.11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything suspicious in there, unless the asyncio server is not closing:
https://github.com/commonism/aiohttp/blob/ebe2a48c282f2484ee1766af5c4d52ff3431b43a/aiohttp/web_runner.py#L83
Everything else looks like it has a 60s timeout, so would fail before the 5 min timeout we're seeing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is the asyncio server not closing, then we should get a cpython bug filed for the regression.
…proto._SSLProtocolTransport object …
for more information, see https://pre-commit.ci
Co-authored-by: Sam Bull <git@sambull.org>
39d9498
to
1ec87be
Compare
This is actually working now. But, I don't know if we want to merge such a complex test after realising that these warnings were already visible in many tests (just ignored in the pytest config), so we already have coverage of this. |
What do these changes do?
Add a test for
ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at …
when using aiohttp.ClientSession with TLS
Are there changes in behavior for the user?
No
Related issue number
#4703
#4713