mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-32410: Make SendfileNotAvailableError exception public (#5243)
This commit is contained in:
parent
2507e29a9e
commit
7464e87a65
6 changed files with 42 additions and 25 deletions
|
@ -154,10 +154,6 @@ def _run_until_complete_cb(fut):
|
|||
futures._get_loop(fut).stop()
|
||||
|
||||
|
||||
class _SendfileNotAvailable(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
class Server(events.AbstractServer):
|
||||
|
||||
def __init__(self, loop, sockets):
|
||||
|
@ -659,17 +655,16 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
try:
|
||||
return await self._sock_sendfile_native(sock, file,
|
||||
offset, count)
|
||||
except _SendfileNotAvailable as exc:
|
||||
if fallback:
|
||||
return await self._sock_sendfile_fallback(sock, file,
|
||||
offset, count)
|
||||
else:
|
||||
raise RuntimeError(exc.args[0]) from None
|
||||
except events.SendfileNotAvailableError as exc:
|
||||
if not fallback:
|
||||
raise
|
||||
return await self._sock_sendfile_fallback(sock, file,
|
||||
offset, count)
|
||||
|
||||
async def _sock_sendfile_native(self, sock, file, offset, count):
|
||||
# NB: sendfile syscall is not supported for SSL sockets and
|
||||
# non-mmap files even if sendfile is supported by OS
|
||||
raise _SendfileNotAvailable(
|
||||
raise events.SendfileNotAvailableError(
|
||||
f"syscall sendfile is not available for socket {sock!r} "
|
||||
"and file {file!r} combination")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue