Closed PJ-Schulz closed 3 months ago
It is correct it worked earlier and no longer works.
Please see the release notes, it is a documented change.
Since it is an async client, you need to instantiate it with a running loop, which anyhow seems logical.
Allowing the async client or server to be instantiated without a running loop gave all kinds of nasty racing problems.
And just to be clear, the client class constructor is synchronous but lower parts of the code depends on asyncio to work.
As far as I know you cannot define init as async (I haven't tried).
Versions
Pymodbus Specific
Description
Hello, I found something which works in pymodbus 3.6.4 but not in 3.6.5, 3.6.6.
Previously in version 3.6.4 I could create the client outside of an async function started with asyncio. With the newer versions this is no longer possible. If the client is now created outside, a
RuntimeError: no running event loop
is raised.The constructor itself is synchronous. I am surprised that I first have to create an asyncio event loop and then call the constructor.
I think the change came in this PR: #2046
Code and Logs