Skip to content

Commit

Permalink
pythongh-109370: Fix unexpected traceback output in test_concurrent_f…
Browse files Browse the repository at this point in the history
…utures

Follow-up of pythongh-107219.

* Only close the connection writer on Windows.
* Also use existing constant _winapi.ERROR_OPERATION_ABORTED instead of
  WSA_OPERATION_ABORTED.
  • Loading branch information
serhiy-storchaka committed Sep 23, 2023
1 parent e8be0c9 commit 3030774
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Lib/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ def terminate_broken(self, cause):

# gh-107219: Close the connection writer which can unblock
# 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
self.join_executor_internals()
Expand Down
3 changes: 1 addition & 2 deletions Lib/multiprocessing/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
BUFSIZE = 8192
# A very generous timeout when it comes to local connections...
CONNECTION_TIMEOUT = 20.
WSA_OPERATION_ABORTED = 995

_mmap_counter = itertools.count()

Expand Down Expand Up @@ -300,7 +299,7 @@ def _send_bytes(self, buf):
finally:
self._send_ov = None
nwritten, err = ov.GetOverlappedResult(True)
if err == WSA_OPERATION_ABORTED:
if err == _winapi.ERROR_OPERATION_ABORTED:
# close() was called by another thread while
# WaitForMultipleObjects() was waiting for the overlapped
# operation.
Expand Down

0 comments on commit 3030774

Please sign in to comment.