Skip to content

Fix SSL connection testing in Python 3.7 #1661

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

Closed
wants to merge 8 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ docs/_build
integration-test/
tests-env/
.pytest_cache/
venv/
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me to add, but as a separate commit from the SSL fix.

However your commit history is a mess, so normally I'd merge this PR by squashing... but that would conflict with above...

3 changes: 3 additions & 0 deletions build_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ pushd servers
fi
echo
echo "Extracting kafka ${kafka} binaries"
if [ ! -d ../$kafka ]; then
mkdir ../$kafka
fi
Copy link
Contributor

@jeffwidman jeffwidman Dec 1, 2018

Choose a reason for hiding this comment

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

Like the .gitignore change, this feels like a distinct PR / commit which wouldn't happen if I merge by squashing

tar xzvf ${KAFKA_ARTIFACT} -C ../$kafka/
rm -rf ../$kafka/kafka-bin
mv ../$kafka/${KAFKA_ARTIFACT/%.t*/} ../$kafka/kafka-bin
Expand Down
7 changes: 7 additions & 0 deletions kafka/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ def connect(self):
ret = self._sock.connect_ex(self._sock_addr)
except socket.error as err:
ret = err.errno
except ValueError as err:
# Python 3.7 and higher raises ValueError if a socket
# is already connected
if sys.version_info >= (3, 7):
ret = None
else:
raise err
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, you only need this to be raise and it will re-raise the most recent one


# Connection succeeded
if not ret or ret == errno.EISCONN:
Expand Down