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

feat: when testing connection, set timeout to 10s when checking if port is opened [TCTC-7385] #1772

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fix

- When testing connection, set timeout to 10s when checking if port is opened.

## [7.0.2] 2024-09-13

### Changed
Expand Down
3 changes: 3 additions & 0 deletions toucan_connectors/toucan_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
if TYPE_CHECKING: # pragma: no cover
import pandas as pd

TIMEOUT_CHECK_PORT = 10 # consider port closed if > 10 seconds


LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -383,6 +385,7 @@ def check_hostname(hostname):
@staticmethod
def check_port(host, port):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(TIMEOUT_CHECK_PORT)
s.connect((host, port))

def get_status(self) -> ConnectorStatus:
Expand Down