-
Notifications
You must be signed in to change notification settings - Fork 951
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
fixes access to asyncio loop via loop property of SerialTransport #1804
Conversation
…nsport via its loop property
Please solve the CI errors. |
… but there seems no method to get the loop from a asyncio.BaseProtocol.
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.
The production code change is ok, but please remove the test, for the reasons mentioned.
test/sub_transport/test_basic.py
Outdated
@@ -292,6 +292,17 @@ async def test_init(self): | |||
"""Test null modem init""" | |||
SerialTransport(asyncio.get_running_loop(), mock.Mock(), "dummy") | |||
|
|||
async def test_loop(self): |
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.
We do not test that the libraries work correctly, so I see this test as not needed.
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 added this test more as illustration that something is wrong in the original code. I will remove it.
Please check again the production code change. Is the "protocol" event loop necessarily always the same as the one of the transport? Anyhow, the original access was faulty.
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.
LGtM, thanks.
The property loop of SerialTransport (
transport_seria.py
) is defined aswith
self._protocol
of typeasyncio.protocols.BaseProtocol
which does not feature an attributeloop
, but instead holds the asyncio event loop in the attribute_loop
thus this definition should read correctlyThere are two further occurrences of accessing the event loop of the
_protocol
instances via the attributeloop
instead of_loop
(in_read_ready
and_write_ready
). This PR fixes those and adds a test that demonstrates the issue.