[3.12] gh-109370: Fix unexpected traceback output in test_concurrent_futures (GH-109780) (GH-111934)

Follow-up of gh-107219.

* Only close the connection writer on Windows.
* Also use existing constant _winapi.ERROR_OPERATION_ABORTED instead of
  WSA_OPERATION_ABORTED.
(cherry picked from commit 0b4e090422)
This commit is contained in:
Serhiy Storchaka 2023-11-10 09:17:02 +02:00 committed by GitHub
parent 5a8e6f8bcc
commit 4018209fff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -526,7 +526,8 @@ class _ExecutorManagerThread(threading.Thread):
# gh-107219: Close the connection writer which can unblock # gh-107219: Close the connection writer which can unblock
# Queue._feed() if it was stuck in send_bytes(). # Queue._feed() if it was stuck in send_bytes().
self.call_queue._writer.close() if sys.platform == 'win32':
self.call_queue._writer.close()
# clean up resources # clean up resources
self._join_executor_internals(broken=True) self._join_executor_internals(broken=True)

View file

@ -42,7 +42,6 @@ except ImportError:
BUFSIZE = 8192 BUFSIZE = 8192
# A very generous timeout when it comes to local connections... # A very generous timeout when it comes to local connections...
CONNECTION_TIMEOUT = 20. CONNECTION_TIMEOUT = 20.
WSA_OPERATION_ABORTED = 995
_mmap_counter = itertools.count() _mmap_counter = itertools.count()
@ -300,7 +299,7 @@ if _winapi:
finally: finally:
self._send_ov = None self._send_ov = None
nwritten, err = ov.GetOverlappedResult(True) nwritten, err = ov.GetOverlappedResult(True)
if err == WSA_OPERATION_ABORTED: if err == _winapi.ERROR_OPERATION_ABORTED:
# close() was called by another thread while # close() was called by another thread while
# WaitForMultipleObjects() was waiting for the overlapped # WaitForMultipleObjects() was waiting for the overlapped
# operation. # operation.