Skip to content

Eliminiate implicit optional in reconnect_delay* #1874

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

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pymodbus/transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CommParams:
comm_name: str | None = None
comm_type: CommType | None = None
reconnect_delay: float | None = None
reconnect_delay_max: float | None = None
reconnect_delay_max: float = 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually there is a hidden problem here, "reconnect_delay_max" is defined a milliseconds and is an integer.

It seems asyncio.py does still use seconds, so I have to look at code before I approve this one.

timeout_connect: float | None = None
host: str = "127.0.0.1"
port: int = 0
Expand Down Expand Up @@ -433,7 +433,7 @@ def transport_close(self, intern: bool = False, reconnect: bool = False) -> None

def reset_delay(self) -> None:
"""Reset wait time before next reconnect to minimal period."""
self.reconnect_delay_current = self.comm_params.reconnect_delay
self.reconnect_delay_current = self.comm_params.reconnect_delay or 0.0

def is_active(self) -> bool:
"""Return true if connected/listening."""
Expand Down Expand Up @@ -468,7 +468,7 @@ def handle_new_connection(self) -> ModbusProtocol:
async def do_reconnect(self) -> None:
"""Handle reconnect as a task."""
try:
self.reconnect_delay_current = self.comm_params.reconnect_delay
self.reconnect_delay_current = self.comm_params.reconnect_delay or 0.0
while True:
Log.debug(
"Wait {} {} ms before reconnecting.",
Expand Down