##// END OF EJS Templates
feat(svn): improvements to handle SVN protocol 1.4 features...
feat(svn): improvements to handle SVN protocol 1.4 features - added support to actually allow HEAD type calls - support HEAD / DELETE calls properly with new requets - use request session for performance optimization on making a lot of calls.

File last commit:

r5096:a0018795 default
r5215:e17d6d15 default
Show More
statsd_client.py
49 lines | 1.2 KiB | text/x-python | PythonLexer
from rhodecode.lib._vendor.statsd import client_from_config
class StatsdClientNotInitialised(Exception):
pass
class _Singleton(type):
"""A metaclass that creates a Singleton base class when called."""
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super().__call__(*args, **kwargs)
return cls._instances[cls]
class Singleton(_Singleton("SingletonMeta", (object,), {})):
pass
class StatsdClientClass(Singleton):
setup_run = False
statsd_client = None
statsd = None
def __getattribute__(self, name):
if name.startswith("statsd"):
if self.setup_run:
return super().__getattribute__(name)
else:
return None
#raise StatsdClientNotInitialised("requested key was %s" % name)
return super().__getattribute__(name)
def setup(self, settings):
"""
Initialize the client
"""
statsd = client_from_config(settings)
self.statsd = statsd
self.statsd_client = statsd
self.setup_run = True
StatsdClient = StatsdClientClass()