<s> from __future__ import absolute_import , division , print_function , unicode_literals <EOL> __metaclass__ = type <EOL> import logging <EOL> import time <EOL> from functools import wraps <EOL> from . import compat <EOL> compat . patch ( ) <EOL> log = logging . getLogger ( '<STR_LIT>' ) <EOL> def synchronized ( lock_name ) : <EOL> """<STR_LIT>""" <EOL> def decorator ( f ) : <EOL> @ wraps ( f ) <EOL> def wrapper ( self , * args , ** kwargs ) : <EOL> lock = getattr ( self , lock_name ) <EOL> acquired = lock . acquire ( False ) <EOL> if not acquired : <EOL> start_time = time . perf_counter ( ) <EOL> lock . acquire ( ) <EOL> tot_time = time . perf_counter ( ) - start_time <EOL> if tot_time > <NUM_LIT:5> : <EOL> log . warn ( '<STR_LIT>' . format ( f . __qualname__ , tot_time ) ) <EOL> try : <EOL> retval = f ( self , * args , ** kwargs ) <EOL> finally : <EOL> lock . release ( ) <EOL> return retval <EOL> return wrapper <EOL> return decorator </s>
