@contextlib.contextmanager
def use_master():
 old = getattr(multidb.pinning._locals, 'pinned', False)
 multidb.pinning.pin_this_thread()
 try:
  (yield)
 finally:
  multidb.pinning._locals.pinned = old

@ contextlib . contextmanager def use_master ( ) : old = getattr ( multidb . pinning . _locals , 'pinned' , False ) multidb . pinning . pin_this_thread ( ) try : ( yield ) finally : multidb . pinning . _locals . pinned = old
within this context .