<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import threading <EOL> from contextlib import contextmanager <EOL> class LocalContextMixin ( object ) : <EOL> _lcm_context = None <EOL> def __init__ ( self ) : <EOL> self . _lcm_context = threading . local ( ) <EOL> @ contextmanager <EOL> def push_context ( self , context ) : <EOL> """<STR_LIT>""" <EOL> cur_ctx = self . set_context ( context ) <EOL> try : <EOL> yield context <EOL> finally : <EOL> self . set_context ( cur_ctx ) <EOL> def set_context ( self , context ) : <EOL> """<STR_LIT>""" <EOL> cur_ctx = self . get_context ( ) <EOL> self . _lcm_context . ctx = context <EOL> return cur_ctx <EOL> def get_context ( self ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( self . _lcm_context , '<STR_LIT>' ) : <EOL> return self . _lcm_context . ctx <EOL> return None </s>
