• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import atexit
6import logging
7
8
9def _WrapFunction(function):
10  def _WrappedFn(*args, **kwargs):
11    logging.debug('Try running %s', repr(function))
12    try:
13      function(*args, **kwargs)
14      logging.debug('Did run %s', repr(function))
15    except Exception:  # pylint: disable=broad-except
16      logging.exception('Exception running %s', repr(function))
17  return _WrappedFn
18
19
20def Register(function, *args, **kwargs):
21  atexit.register(_WrapFunction(function), *args, **kwargs)
22