Use explicit import

... to avoid pep8 errors caused by implicit import of a few modules.
This commit is contained in:
Takashi Kajinami 2025-06-09 21:37:30 +09:00
parent 21ed8747e2
commit 10889ff79b
1 changed files with 11 additions and 7 deletions

View File

@ -17,13 +17,17 @@ import multiprocessing
from http.server import SimpleHTTPRequestHandler from http.server import SimpleHTTPRequestHandler
# Degraded functionality if these imports are missing # Degraded functionality if these imports are missing
for mod, msg in [('ssl', 'TLS/SSL/wss is disabled'), try:
('resource', 'daemonizing is disabled')]: import ssl
try: except ImportError:
globals()[mod] = __import__(mod) ssl = None
except ImportError: print("WARNING: no 'ssl' module, TLS/SSL/wss is disabled")
globals()[mod] is None
print("WARNING: no '%s' module, %s" % (mod, msg)) try:
import resource
except ImportError:
resource = None
print("WARNING: no 'resource' module, daemonizing is disabled")
if sys.platform == 'win32': if sys.platform == 'win32':
# make sockets pickle-able/inheritable # make sockets pickle-able/inheritable