Use oslo_utils reflection to get 'f' callable name
Using the utility function gets a better name. For example: $ python >>> from oslo_utils import reflection >>> class A(object): ... def m(self): ... pass ... >>> z = A() >>> reflection.get_callable_name(z.m) '__main__.A.m' Versus: >>> z.m.__name__ 'm' Change-Id: I2daadd969383aaf49ad87876ba108dd80dd56f08
This commit is contained in:
parent
4ff6635921
commit
3aaa63986c
@ -26,6 +26,7 @@ import weakref
|
|||||||
|
|
||||||
import fasteners
|
import fasteners
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_utils import reflection
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
@ -247,7 +248,8 @@ def synchronized(name, lock_file_prefix=None, external=False, lock_path=None,
|
|||||||
t2 = timeutils.now()
|
t2 = timeutils.now()
|
||||||
LOG.debug('Lock "%(name)s" acquired by "%(function)s" :: '
|
LOG.debug('Lock "%(name)s" acquired by "%(function)s" :: '
|
||||||
'waited %(wait_secs)0.3fs',
|
'waited %(wait_secs)0.3fs',
|
||||||
{'name': name, 'function': f.__name__,
|
{'name': name,
|
||||||
|
'function': reflection.get_callable_name(f),
|
||||||
'wait_secs': (t2 - t1)})
|
'wait_secs': (t2 - t1)})
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
finally:
|
finally:
|
||||||
@ -258,7 +260,8 @@ def synchronized(name, lock_file_prefix=None, external=False, lock_path=None,
|
|||||||
held_secs = "%0.3fs" % (t3 - t2)
|
held_secs = "%0.3fs" % (t3 - t2)
|
||||||
LOG.debug('Lock "%(name)s" released by "%(function)s" :: held '
|
LOG.debug('Lock "%(name)s" released by "%(function)s" :: held '
|
||||||
'%(held_secs)s',
|
'%(held_secs)s',
|
||||||
{'name': name, 'function': f.__name__,
|
{'name': name,
|
||||||
|
'function': reflection.get_callable_name(f),
|
||||||
'held_secs': held_secs})
|
'held_secs': held_secs})
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user