-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
bpo-30329: Catch Windows error 10022 on shutdown() #1538
Conversation
@Haypo, thanks for your PR! By analyzing the history of the files in this pull request, we identified @tim-one, @tiran and @bitdancer to be potential reviewers. |
Lib/imaplib.py
Outdated
if e.errno != errno.ENOTCONN: | ||
except OSError as exc: | ||
# The server might already have closed the connection. | ||
# Windows error 10022: An invalid operation was attempted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change the comment to "On Windows, this may result in Windows error 10022: An invalid operation was attempted". At least, I hope that's why we're getting that error. (In my experience invalid operation is indeed what windows raises when you attempt an operation on a closed socket).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(In my experience invalid operation is indeed what windows raises when you attempt an operation on a closed socket).
I failed to reproduce the error on Windows on a closed socket. If the socket is closed, its socket handle becomes -1. Calling shutdown() with the socket handle -1 is not a good idea. It would be better to raise an exception rather than calling shutdown() if the socket is known to be closed, but I'm too shy to propose such change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change the comment to "On Windows, this may result in Windows error 10022: An invalid operation was attempted".
Done
Catch the Windows socket WSAEINVAL error (code 10022) in imaplib and poplib on shutdown(SHUT_RDWR): An invalid operation was attempted This error occurs sometimes on SSL connections.
Catch the Windows socket error 10022 (An invalid operation was
attempted) on shutdown(SHUT_RDWR) in imaplib and poplib. This error
occurs sometimes on SSL connections.