Skip to content
Merged
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
gh-98174: Handle EPROTOTYPE under macOS in test_sendfile_fallback_clo…
…se_peer_in_the_middle_of_receiving (GH-98316)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
(cherry picked from commit 3e82ad0)

Co-authored-by: fancidev <fancidev@gmail.com>
  • Loading branch information
fancidev authored and miss-islington committed Oct 17, 2022
commit 29f4a4416406923af7c5d6c8c08c1bca6f07763b
14 changes: 12 additions & 2 deletions Lib/test/test_asyncio/test_sendfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for sendfile functionality."""

import asyncio
import errno
import os
import socket
import sys
Expand Down Expand Up @@ -484,8 +485,17 @@ def sendfile_native(transp, file, offset, count):

srv_proto, cli_proto = self.prepare_sendfile(close_after=1024)
with self.assertRaises(ConnectionError):
self.run_loop(
self.loop.sendfile(cli_proto.transport, self.file))
try:
self.run_loop(
self.loop.sendfile(cli_proto.transport, self.file))
except OSError as e:
# macOS may raise OSError of EPROTOTYPE when writing to a
# socket that is in the process of closing down.
if e.errno == errno.EPROTOTYPE and sys.platform == "darwin":
raise ConnectionError
else:
raise

self.run_loop(srv_proto.done)

self.assertTrue(1024 <= srv_proto.nbytes < len(self.DATA),
Expand Down