From fc177726e1779eb8408abed0593587da591fab4d Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sat, 16 Jun 2018 16:27:11 -0700 Subject: [PATCH] cli.py: move timing check back to top We care about how long it takes to import all the wormhole-specific things, to investigate user-perceived latency from the time the command is launched to the time they can actually interact with it. So we need to record `time.time()` before doing the rest of the imports, even though pep8 says all imports should be done before any non-importing statements. --- src/wormhole/cli/cli.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/wormhole/cli/cli.py b/src/wormhole/cli/cli.py index ba74157..292d662 100644 --- a/src/wormhole/cli/cli.py +++ b/src/wormhole/cli/cli.py @@ -2,23 +2,24 @@ from __future__ import print_function import os import time -from sys import stderr, stdout -from textwrap import dedent, fill +start = time.time() -import click -import six -from twisted.internet.defer import inlineCallbacks, maybeDeferred -from twisted.internet.task import react -from twisted.python.failure import Failure +from sys import stderr, stdout # noqa: E402 +from textwrap import dedent, fill # noqa: E402 -from . import public_relay -from .. import __version__ -from ..errors import (KeyFormatError, NoTorError, ServerConnectionError, +import click # noqa: E402 +import six # noqa: E402 +from twisted.internet.defer import inlineCallbacks, maybeDeferred # noqa: E402 +from twisted.internet.task import react # noqa: E402 +from twisted.python.failure import Failure # noqa: E402 + +from . import public_relay # noqa: E402 +from .. import __version__ # noqa: E402 +from ..errors import (KeyFormatError, NoTorError, # noqa: E402 + ServerConnectionError, TransferError, UnsendableFileError, WelcomeError, WrongPasswordError) -from ..timing import DebugTiming - -start = time.time() +from ..timing import DebugTiming # noqa: E402 top_import_finish = time.time()