Merge pull request #2504 from Suor/http-compat

perf: do not import http.server each run
This commit is contained in:
Ruslan Kuprieiev
2019-09-18 22:27:52 +03:00
committed by GitHub
2 changed files with 7 additions and 8 deletions
-6
View File
@@ -103,8 +103,6 @@ def ignore_file_not_found():
if is_py2:
from urlparse import urlparse, urlunparse, urljoin # noqa: F401
from urllib import urlencode # noqa: F401
from BaseHTTPServer import HTTPServer # noqa: F401
from SimpleHTTPServer import SimpleHTTPRequestHandler # noqa: F401
import ConfigParser # noqa: F401
from io import open # noqa: F401
import pathlib2 as pathlib # noqa: F401
@@ -150,10 +148,6 @@ elif is_py3:
urljoin, # noqa: F401
)
from io import StringIO, BytesIO # noqa: F401
from http.server import ( # noqa: F401
HTTPServer, # noqa: F401
SimpleHTTPRequestHandler, # noqa: F401
) # noqa: F401
import configparser as ConfigParser # noqa: F401
from collections.abc import Mapping # noqa: F401
+7 -2
View File
@@ -2,9 +2,14 @@ import hashlib
import os
import threading
from RangeHTTPServer import RangeRequestHandler
# Moved in Python 2 -> 3, used only here.
# Not adding to dvc.utils.compat to not load http.server for non-test runs.
try:
from http.server import HTTPServer
except ImportError:
from BaseHTTPServer import HTTPServer
from dvc.utils.compat import HTTPServer
from RangeHTTPServer import RangeRequestHandler
class TestRequestHandler(RangeRequestHandler):