@contextlib.contextmanager
def flopen(*args, **kwargs):
 with fopen(*args, **kwargs) as fhandle:
  try:
   if is_fcntl_available(check_sunos=True):
    fcntl.flock(fhandle.fileno(), fcntl.LOCK_SH)
   (yield fhandle)
  finally:
   if is_fcntl_available(check_sunos=True):
    fcntl.flock(fhandle.fileno(), fcntl.LOCK_UN)

@ contextlib . contextmanager def flopen ( * args , ** kwargs ) : with fopen ( * args , ** kwargs ) as fhandle : try : if is_fcntl_available ( check_sunos = True ) : fcntl . flock ( fhandle . fileno ( ) , fcntl . LOCK_SH ) ( yield fhandle ) finally : if is_fcntl_available ( check_sunos = True ) : fcntl . flock ( fhandle . fileno ( ) , fcntl . LOCK_UN )
shortcut for fopen with lock and context manager .