Skip to content
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

server/asyncio.py change in the _log_exception method to correct the logging when disconnecting the socket #1135

Merged
merged 5 commits into from
Oct 23, 2022

Conversation

alexandrecuer
Copy link
Contributor

in the _log_exception method :

  • all logging should be debug and not error
  • no logging should be thrown if the handler is not running, otherwise cancellation messages are duplicated, we see the first cancellation message at the closing stage and the same is shown when we enter the closed state

this answers to #1110 (reply in thread)

cf #1110 (comment)

this removes the error, when running a TCP server forwarding a serial server :
```
17:10:21 ERROR mixin:113 Please do not use unit=, convert to slave=.
````
ReadRegistersRequestBase cf ResponseBase
in the _log_exception method :  
- all logging should be debug and not error
- no logging should be thrown if the handler is not running, otherwise cancellation messages are duplicated, we see the first cancellation message at the closing stage and the same is shown when we enter the closed state

this answers to #1110 (reply in thread)
@@ -100,11 +100,13 @@ def __init__(self, owner):

def _log_exception(self):
"""Show log exception."""
if not self.running:
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log exception can occur before and especially after server is running.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _log_exception() is only called twice, in handle() when self.running is True and in connection_lost(), so always after server is running. But maybe i missunderstand something

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_log_exception can be called from anywhere, we add/remove _log_exception often. Apart from that it is not logical nor correct that _log_exception depends on the state of the server.

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@janiversen janiversen merged commit b294096 into pymodbus-dev:dev Oct 23, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants