fix(async): synchronize connect() promise with connection_made callback - #3021
fix(async): synchronize connect() promise with connection_made callback#3021Yuvrajup wants to merge 5 commits into
Conversation
janiversen
left a comment
There was a problem hiding this comment.
This is overly complicated and not needed, current solution uses the standard asyncio methods.
client,connect returns the value comming from asyncio, which according to the documentation is true/false depending on whether a connection was established.
client.connected tests if the connection is stil open by referring to the transport object. Remark connection_made/ connection_lost changes the transport object.
The issue you refer to, is not actually an issue in pymodbus (see the discussion) but a device problem.
janiversen
left a comment
There was a problem hiding this comment.
If you want this merged, you need to make a test case that shows that the current solution is wrong and yours work.
|
Challenge accepted, @janiversen! I completely understand wanting to keep the library lean and relying on standard You are right that I just pushed a new test case (
Let me know what you think of the test case! |
|
Forget about that race, pymodbus do not have the transport object until connection_made is called. Apart from that in my experience, when debugging, connection_made was always called before the connect returned. Just checked your test case, the delay is inside connection_made() and thus in pymodbus code, so your test case does not show if connection_made is called before connect returns. |
Closes #3019