main: Use timer.time_logger helper
This commit is contained in:
parent
d9347b1348
commit
779a399c59
@ -2,11 +2,9 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
import glib
|
||||
|
||||
@ -15,7 +13,7 @@ import gobject
|
||||
from mopidy import config as config_lib, exceptions
|
||||
from mopidy.audio import Audio
|
||||
from mopidy.core import Core
|
||||
from mopidy.utils import deps, process, versioning
|
||||
from mopidy.utils import deps, process, timer, versioning
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -65,13 +63,6 @@ class _HelpAction(argparse.Action):
|
||||
raise _HelpError()
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _startup_timer(name):
|
||||
start = time.time()
|
||||
yield
|
||||
logger.debug('%s startup took %dms', name, (time.time() - start) * 1000)
|
||||
|
||||
|
||||
class Command(object):
|
||||
"""Command parser and runner for building trees of commands.
|
||||
|
||||
@ -356,7 +347,7 @@ class RootCommand(Command):
|
||||
backends = []
|
||||
for backend_class in backend_classes:
|
||||
try:
|
||||
with _startup_timer(backend_class.__name__):
|
||||
with timer.time_logger(backend_class.__name__):
|
||||
backend = backend_class.start(
|
||||
config=config, audio=audio).proxy()
|
||||
backends.append(backend)
|
||||
@ -379,7 +370,7 @@ class RootCommand(Command):
|
||||
|
||||
for frontend_class in frontend_classes:
|
||||
try:
|
||||
with _startup_timer(frontend_class.__name__):
|
||||
with timer.time_logger(frontend_class.__name__):
|
||||
frontend_class.start(config=config, core=core)
|
||||
except exceptions.FrontendError as exc:
|
||||
logger.error(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user