bpo-32410: Make SendfileNotAvailableError exception public (#5243)

This commit is contained in:
Andrew Svetlov 2018-01-19 20:04:29 +02:00 committed by GitHub
parent 2507e29a9e
commit 7464e87a65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 25 deletions

View file

@ -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")