<s> import warnings <EOL> from django . core import signals <EOL> from django . db . utils import ( DEFAULT_DB_ALIAS , <EOL> DataError , OperationalError , IntegrityError , InternalError , <EOL> ProgrammingError , NotSupportedError , DatabaseError , <EOL> InterfaceError , Error , <EOL> load_backend , ConnectionHandler , ConnectionRouter ) <EOL> from django . utils . functional import cached_property <EOL> __all__ = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> connections = ConnectionHandler ( ) <EOL> router = ConnectionRouter ( ) <EOL> class DefaultConnectionProxy ( object ) : <EOL> """<STR_LIT>""" <EOL> def __getattr__ ( self , item ) : <EOL> return getattr ( connections [ DEFAULT_DB_ALIAS ] , item ) <EOL> def __setattr__ ( self , name , value ) : <EOL> return setattr ( connections [ DEFAULT_DB_ALIAS ] , name , value ) <EOL> def __delattr__ ( self , name ) : <EOL> return delattr ( connections [ DEFAULT_DB_ALIAS ] , name ) <EOL> connection = DefaultConnectionProxy ( ) <EOL> class DefaultBackendProxy ( object ) : <EOL> """<STR_LIT>""" <EOL> @ cached_property <EOL> def _backend ( self ) : <EOL> warnings . warn ( "<STR_LIT>" , <EOL> PendingDeprecationWarning , stacklevel = <NUM_LIT:2> ) <EOL> return load_backend ( connections [ DEFAULT_DB_ALIAS ] . settings_dict [ '<STR_LIT>' ] ) <EOL> def __getattr__ ( self , item ) : <EOL> return getattr ( self . _backend , item ) <EOL> def __setattr__ ( self , name , value ) : <EOL> return setattr ( self . _backend , name , value ) <EOL> def __delattr__ ( self , name ) : <EOL> return delattr ( self . _backend , name ) <EOL> backend = DefaultBackendProxy ( ) <EOL> def close_connection ( ** kwargs ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> PendingDeprecationWarning , stacklevel = <NUM_LIT:2> ) <EOL> from django . db import transaction <EOL> for conn in connections : <EOL> transaction . abort ( conn ) <EOL> connections [ conn ] . close ( ) <EOL> def reset_queries ( ** kwargs ) : <EOL> for conn in connections . all ( ) : <EOL> conn . queries = [ ] <EOL> signals . request_started . connect ( reset_queries ) <EOL> def close_old_connections ( ** kwargs ) : <EOL> for conn in connections . all ( ) : <EOL> try : <EOL> conn . abort ( ) <EOL> except DatabaseError : <EOL> pass <EOL> conn . close_if_unusable_or_obsolete ( ) <EOL> signals . request_started . connect ( close_old_connections ) <EOL> signals . request_finished . connect ( close_old_connections ) </s>
