| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1082,10 +1082,11 @@ async def inner(httpd): | |
| self.assertEqual(data, b'HTTP/1.0 200 OK\r\n') | ||
| data = await rd.read() | ||
| self.assertTrue(data.endswith(b'\r\n\r\nTest message')) | ||
| with self.assertWarns(ResourceWarning): | ||
| with self.assertWarns(ResourceWarning) as cm: | ||
| del wr | ||
| gc.collect() | ||
|
|
||
| self.assertEqual(len(cm.warnings), 1) | ||
| self.assertTrue(str(cm.warnings[0].message).startswith("unclosed <StreamWriter")) | ||
|
|
||
| messages = [] | ||
| self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx)) | ||
| Expand All | @@ -1095,6 +1096,42 @@ async def inner(httpd): | |
|
|
||
| self.assertEqual(messages, []) | ||
|
|
||
| def test_loop_is_closed_resource_warnings(self): | ||
| async def inner(httpd): | ||
| rd, wr = await asyncio.open_connection(*httpd.address) | ||
|
|
||
| wr.write(b'GET / HTTP/1.0\r\n\r\n') | ||
| data = await rd.readline() | ||
| self.assertEqual(data, b'HTTP/1.0 200 OK\r\n') | ||
| data = await rd.read() | ||
| self.assertTrue(data.endswith(b'\r\n\r\nTest message')) | ||
|
|
||
| # Make "loop is closed" occur first before "del wr" for this test. | ||
| self.loop.stop() | ||
| wr.close() | ||
| while not self.loop.is_closed(): | ||
| await asyncio.sleep(0.0) | ||
|
|
||
| with self.assertWarns(ResourceWarning) as cm: | ||
| del wr | ||
| gc.collect() | ||
| self.assertEqual(len(cm.warnings), 1) | ||
| self.assertEqual("loop is closed", str(cm.warnings[0].message)) | ||
|
|
||
| messages = [] | ||
| self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx)) | ||
|
|
||
| with test_utils.run_test_server() as httpd: | ||
| try: | ||
| self.loop.run_until_complete(inner(httpd)) | ||
| # This exception is caused by `self.loop.stop()` as expected. | ||
| except RuntimeError: | ||
| pass | ||
|
Comment thread
Comment on lines
+1128
to
+1129
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAdd a comment at least showing why we expectRuntimeError here.
Sorry, something went wrong.
dpr-0 reacted with thumbs up emoji
All reactions
|
||
| finally: | ||
| gc.collect() | ||
|
|
||
| self.assertEqual(messages, []) | ||
|
|
||
| def test_unhandled_exceptions(self) -> None: | ||
| port = socket_helper.find_unused_port() | ||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Issue warning message instead of having :class:`RuntimeError` be displayed when event loop has already been closed at :meth:`StreamWriter.__del__`. |
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIf this exception is expected then why not use self.assertRaises etc?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityexcept allows/tolerates an exception, assert requires one and will fail if it does not happen because of other improvements.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.