replace magic numbers with errno.*

This commit is contained in:
ed
2022-10-19 15:21:48 +02:00
parent 046b494b53
commit 20c6b82bec
5 changed files with 53 additions and 22 deletions

View File

@@ -35,6 +35,7 @@ from .util import (
FHC,
Garda,
Magician,
E_SCK,
min_ex,
shut_socket,
spack,
@@ -332,7 +333,7 @@ class HttpSrv(object):
cli.run()
except (OSError, socket.error) as ex:
if ex.errno not in [10038, 10054, 107, 57, 49, 9]:
if ex.errno not in E_SCK:
self.log(
"%s %s" % addr,
"run({}): {}".format(fno, ex),
@@ -354,13 +355,7 @@ class HttpSrv(object):
"shut({}): {}".format(fno, ex),
c="1;30",
)
if ex.errno not in [10038, 10054, 107, 57, 49, 9]:
# 10038 No longer considered a socket
# 10054 Foribly closed by remote
# 107 Transport endpoint not connected
# 57 Socket is not connected
# 49 Can't assign requested address (wifi down)
# 9 Bad file descriptor
if ex.errno not in E_SCK:
raise
finally:
with self.mutex: