Skip to content

Conversation

@dhoomakethu
Copy link
Contributor

version 2.5.3

  • Fix retries on tcp client failing randomly.
  • Fix Asyncio client timeout arg not being used.

@dhoomakethu dhoomakethu changed the base branch from master to dev August 1, 2021 13:27
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 1, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Akkarine
Copy link

Akkarine commented Aug 5, 2021

I'm also have issue with #657. When will this PR be merged?

@dhoomakethu
Copy link
Contributor Author

@Akkarine Please give a try with https://pypi.org/project/pymodbus/2.5.3rc1/

Copy link

@rojikada rojikada left a comment

Choose a reason for hiding this comment

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

This fix for the timeout fixes the timeout, but breaks loop argument. One of the possible solutions is to filter out already specified arguments from the function calls

"""
self.framer = framer
ReconnectingAsyncioModbusTcpClient.__init__(self, protocol_class, loop)
ReconnectingAsyncioModbusTcpClient.__init__(self, protocol_class, loop, **kwargs)

Choose a reason for hiding this comment

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

before this, remove protocol_class and loop from kwargs

Factory function to create initialized protocol instance.
"""
protocol = self.protocol_class(framer=self.framer)
protocol = self.protocol_class(framer=self.framer, **self._proto_args)

Choose a reason for hiding this comment

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

before this, remove framer from self._proto_args

DELAY_MAX_MS = 1000 * 60 * 5

def __init__(self, protocol_class=None, loop=None):
def __init__(self, protocol_class=None, loop=None, **kwargs):

Choose a reason for hiding this comment

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

before this, remove protocol_class and loop from kwargs

"""
client = ReconnectingAsyncioModbusTcpClient(protocol_class=proto_cls,
loop=loop)
loop=loop, **kwargs)

Choose a reason for hiding this comment

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

before this, remove loop and protocol_class from kwargs

client = ReconnectingAsyncioModbusTlsClient(protocol_class=proto_cls,
loop=loop, framer=framer)
loop=loop, framer=framer,
**kwargs)

Choose a reason for hiding this comment

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

before this, remove loop and framer from kwargs

"""
client = ReconnectingAsyncioModbusUdpClient(protocol_class=proto_cls,
loop=loop)
loop=loop, **kwargs)

Choose a reason for hiding this comment

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

before this, remove from kwargs (i.e. {arg:argv[arg] for arg in kwargs if arg not in ["loop", "protocol_class"]}

if not loop.is_running():
asyncio.set_event_loop(loop)
cor = init_tcp_client(proto_cls, loop, host, port)
cor = init_tcp_client(proto_cls, loop, host, port, **kwargs)

Choose a reason for hiding this comment

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

before this, remove from kwargs (i.e. {arg:argv[arg] for arg in kwargs if arg not in ["proto_cls","loop","host","port"]}

client = loop.run_until_complete(asyncio.gather(cor))[0]
else:
cor = init_tcp_client(proto_cls, loop, host, port)
cor = init_tcp_client(proto_cls, loop, host, port, **kwargs)

Choose a reason for hiding this comment

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

before this, remove from kwargs (i.e. {arg:argv[arg] for arg in kwargs if arg not in ["proto_cls","loop","host","port"]}

loop = kwargs.get("loop") or asyncio.get_event_loop()
proto_cls = kwargs.get("proto_cls", None)
cor = init_udp_client(proto_cls, loop, host, port)
cor = init_udp_client(proto_cls, loop, host, port, **kwargs)

Choose a reason for hiding this comment

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

before this, remove from kwargs (i.e. {arg:argv[arg] for arg in kwargs if arg not in ["proto_cls","loop","host","port"]}

@github-actions
Copy link

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dhoomakethu dhoomakethu merged commit d2d1974 into dev Oct 17, 2021
camtarn pushed a commit to camtarn/pymodbus that referenced this pull request Dec 6, 2021
camtarn added a commit to camtarn/pymodbus that referenced this pull request Dec 6, 2021
camtarn added a commit to camtarn/pymodbus that referenced this pull request Dec 6, 2021
@janiversen janiversen deleted the 2.5.3 branch May 10, 2022 10:25
@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.

ModbusTCP _in_waiting not defined. asyncio TCP client timeout broken

4 participants