本文整理汇总了Python中r2.lib.stats.Stats.get_timer方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.get_timer方法的具体用法?Python Stats.get_timer怎么用?Python Stats.get_timer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.lib.stats.Stats
的用法示例。
在下文中一共展示了Stats.get_timer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Globals
# 需要导入模块: from r2.lib.stats import Stats [as 别名]
# 或者: from r2.lib.stats.Stats import get_timer [as 别名]
#.........这里部分代码省略.........
The same variable used throughout ``config/middleware.py``
namely, the variables from the ``[DEFAULT]`` section of the
configuration file.
``app_conf``
The same ``kw`` dictionary used throughout
``config/middleware.py`` namely, the variables from the
section in the config file for your application.
``extra``
The configuration returned from ``load_config`` in
``config/middleware.py`` which may be of use in the setup of
your global variables.
"""
global_conf.setdefault("debug", False)
# reloading site ensures that we have a fresh sys.path to build our
# working set off of. this means that forked worker processes won't get
# the sys.path that was current when the master process was spawned
# meaning that new plugins will be picked up on regular app reload
# rather than having to restart the master process as well.
reload(site)
self.pkg_resources_working_set = pkg_resources.WorkingSet()
self.config = ConfigValueParser(global_conf)
self.config.add_spec(self.spec)
self.plugins = PluginLoader(self.pkg_resources_working_set,
self.config.get("plugins", []))
self.stats = Stats(self.config.get('statsd_addr'),
self.config.get('statsd_sample_rate'))
self.startup_timer = self.stats.get_timer("app_startup")
self.startup_timer.start()
self.paths = paths
self.running_as_script = global_conf.get('running_as_script', False)
# turn on for language support
self.lang = getattr(self, 'site_lang', 'en')
self.languages, self.lang_name = \
get_active_langs(default_lang=self.lang)
all_languages = self.lang_name.keys()
all_languages.sort()
self.all_languages = all_languages
# set default time zone if one is not set
tz = global_conf.get('timezone', 'UTC')
self.tz = pytz.timezone(tz)
dtz = global_conf.get('display_timezone', tz)
self.display_tz = pytz.timezone(dtz)
self.startup_timer.intermediate("init")
def __getattr__(self, name):
if not name.startswith('_') and name in self.config:
return self.config[name]
else:
raise AttributeError
def setup(self):
self.queues = queues.declare_queues(self)
示例2: Globals
# 需要导入模块: from r2.lib.stats import Stats [as 别名]
# 或者: from r2.lib.stats.Stats import get_timer [as 别名]
#.........这里部分代码省略.........
"""
Globals acts as a container for objects available throughout
the life of the application.
One instance of Globals is created by Pylons during
application initialization and is available during requests
via the 'g' variable.
``global_conf``
The same variable used throughout ``config/middleware.py``
namely, the variables from the ``[DEFAULT]`` section of the
configuration file.
``app_conf``
The same ``kw`` dictionary used throughout
``config/middleware.py`` namely, the variables from the
section in the config file for your application.
``extra``
The configuration returned from ``load_config`` in
``config/middleware.py`` which may be of use in the setup of
your global variables.
"""
global_conf.setdefault("debug", False)
self.config = ConfigValueParser(global_conf)
self.config.add_spec(self.spec)
self.plugins = PluginLoader(self.config.get("plugins", []))
self.stats = Stats(self.config.get('statsd_addr'),
self.config.get('statsd_sample_rate'))
self.startup_timer = self.stats.get_timer("app_startup")
self.startup_timer.start()
self.paths = paths
self.running_as_script = global_conf.get('running_as_script', False)
# turn on for language support
self.lang = getattr(self, 'site_lang', 'en')
self.languages, self.lang_name = \
get_active_langs(default_lang=self.lang)
all_languages = self.lang_name.keys()
all_languages.sort()
self.all_languages = all_languages
# set default time zone if one is not set
tz = global_conf.get('timezone', 'UTC')
self.tz = pytz.timezone(tz)
dtz = global_conf.get('display_timezone', tz)
self.display_tz = pytz.timezone(dtz)
self.startup_timer.intermediate("init")
def __getattr__(self, name):
if not name.startswith('_') and name in self.config:
return self.config[name]
else:
raise AttributeError
def setup(self):
self.queues = queues.declare_queues(self)
示例3: Globals
# 需要导入模块: from r2.lib.stats import Stats [as 别名]
# 或者: from r2.lib.stats.Stats import get_timer [as 别名]
#.........这里部分代码省略.........
The same variable used throughout ``config/middleware.py``
namely, the variables from the ``[DEFAULT]`` section of the
configuration file.
``app_conf``
The same ``kw`` dictionary used throughout
``config/middleware.py`` namely, the variables from the
section in the config file for your application.
``extra``
The configuration returned from ``load_config`` in
``config/middleware.py`` which may be of use in the setup of
your global variables.
"""
global_conf.setdefault("debug", False)
# reloading site ensures that we have a fresh sys.path to build our
# working set off of. this means that forked worker processes won't get
# the sys.path that was current when the master process was spawned
# meaning that new plugins will be picked up on regular app reload
# rather than having to restart the master process as well.
reload(site)
self.pkg_resources_working_set = pkg_resources.WorkingSet()
self.config = ConfigValueParser(global_conf)
self.config.add_spec(self.spec)
self.plugins = PluginLoader(self.pkg_resources_working_set,
self.config.get("plugins", []))
self.stats = Stats(self.config.get('statsd_addr'),
self.config.get('statsd_sample_rate'))
self.startup_timer = self.stats.get_timer("app_startup")
self.startup_timer.start()
self.baseplate = Baseplate()
self.baseplate.configure_logging()
self.baseplate.register(R2BaseplateObserver())
self.paths = paths
self.running_as_script = global_conf.get('running_as_script', False)
# turn on for language support
self.lang = getattr(self, 'site_lang', 'en')
self.languages, self.lang_name = get_active_langs(
config, default_lang=self.lang)
all_languages = self.lang_name.keys()
all_languages.sort()
self.all_languages = all_languages
# set default time zone if one is not set
tz = global_conf.get('timezone', 'UTC')
self.tz = pytz.timezone(tz)
dtz = global_conf.get('display_timezone', tz)
self.display_tz = pytz.timezone(dtz)
self.startup_timer.intermediate("init")
def __getattr__(self, name):
if not name.startswith('_') and name in self.config:
return self.config[name]
else:
示例4: Globals
# 需要导入模块: from r2.lib.stats import Stats [as 别名]
# 或者: from r2.lib.stats.Stats import get_timer [as 别名]
#.........这里部分代码省略.........
def __init__(self, global_conf, app_conf, paths, **extra):
"""
Globals acts as a container for objects available throughout
the life of the application.
One instance of Globals is created by Pylons during
application initialization and is available during requests
via the 'g' variable.
``global_conf``
The same variable used throughout ``config/middleware.py``
namely, the variables from the ``[DEFAULT]`` section of the
configuration file.
``app_conf``
The same ``kw`` dictionary used throughout
``config/middleware.py`` namely, the variables from the
section in the config file for your application.
``extra``
The configuration returned from ``load_config`` in
``config/middleware.py`` which may be of use in the setup of
your global variables.
"""
global_conf.setdefault("debug", False)
self.config = ConfigValueParser(global_conf)
self.config.add_spec(self.spec)
self.plugins = PluginLoader(self.config.get("plugins", []))
self.stats = Stats(self.config.get("statsd_addr"), self.config.get("statsd_sample_rate"))
self.startup_timer = self.stats.get_timer("app_startup")
self.startup_timer.start()
self.paths = paths
self.running_as_script = global_conf.get("running_as_script", False)
# turn on for language support
self.lang = getattr(self, "site_lang", "en")
self.languages, self.lang_name = get_active_langs(default_lang=self.lang)
all_languages = self.lang_name.keys()
all_languages.sort()
self.all_languages = all_languages
# set default time zone if one is not set
tz = global_conf.get("timezone", "UTC")
self.tz = pytz.timezone(tz)
dtz = global_conf.get("display_timezone", tz)
self.display_tz = pytz.timezone(dtz)
self.startup_timer.intermediate("init")
def __getattr__(self, name):
if not name.startswith("_") and name in self.config:
return self.config[name]
else:
raise AttributeError
def setup(self):
self.queues = queues.declare_queues(self)