Skip to content

PYTHON-2443 Fix TypeError when pyOpenSSL socket has timeout of None #526

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 1 commit into from
Closed
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: 3 additions & 1 deletion pymongo/socket_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def select(self, sock, read=False, write=False, timeout=0):
try:
Copy link
Member

Choose a reason for hiding this comment

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

Can you please update this method's docstring to say:

        """Select for reads or writes with a timeout in seconds (or None).

# poll() timeout is in milliseconds. select()
# timeout is in seconds.
res = self._poller.poll(timeout * 1000)
# socket.getdefaulttimeout() can return None
timeout_ = timeout * 1000 if timeout is not None else None
Copy link
Member

Choose a reason for hiding this comment

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

Suggest reversing the if/else to shorten the line to <80 chars:

timeout_ = None if timeout is None else timeout * 1000

res = self._poller.poll(timeout_)
# poll returns a possibly-empty list containing
# (fd, event) 2-tuples for the descriptors that have
# events or errors to report. Return True if the list
Expand Down