Replies: 1 comment 2 replies
-
As far as I remember we only call add_writer when there is something to write, which is according to the manual. This is the normal procedure, since it eases sending a new packet to be written. As far as I know the add_writer "dies" when the data at hand have been sent (otherwise it would be constantly polling). However if you have a more efficient solution, then a pull request is welcome. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've been analyzing the
SerialTransport
code in regards to #2205 and I've stumbled upon these four lines:https://github.com/pymodbus-dev/pymodbus/blob/30e4aa759024ee3faec1bc54ff2e689be9c86448/pymodbus/transport/serialtransport.py#L138C1-L141C22
Maybe there's some reason behind calling
add_reader
here again, but I can't find any. The Python's documentation ofadd_reader
is lacking, so I've checked the Python's source code and calling this method for the same file descriptor multiple times is not dangerous, it just replaces old writer with a new one. The writer is not removed unlessremove_writer
is called. This is not a bug, but possibly wastes CPU cycles and delays the return to the loop.Beta Was this translation helpful? Give feedback.
All reactions