mirror of
https://github.com/python/cpython.git
synced 2024-12-18 06:14:00 +08:00
gh-98174: Handle EPROTOTYPE under macOS in test_sendfile_fallback_close_peer_in_the_middle_of_receiving (#98316)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
72c10d3f1a
commit
3e82ad05b1
@ -1,6 +1,7 @@
|
||||
"""Tests for sendfile functionality."""
|
||||
|
||||
import asyncio
|
||||
import errno
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
@ -484,8 +485,17 @@ class SendfileMixin(SendfileBase):
|
||||
|
||||
srv_proto, cli_proto = self.prepare_sendfile(close_after=1024)
|
||||
with self.assertRaises(ConnectionError):
|
||||
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),
|
||||
|
Loading…
Reference in New Issue
Block a user