# Path: aisikl/exceptions.py
# class LoggedOutError(AisiklError):
#     '''Request couldn't be completed because we are no longer logged in.'''


import contextlib
import fcntl
import gzip
import os
import pickle
from aisikl.exceptions import LoggedOutError
            # Lock acquired, but is it still the same file? Compare inodes.
            my_inode = os.fstat(f.fileno()).st_ino
            try:
                inode_on_disk = os.stat(lock_path).st_ino
            except FileNotFoundError:
                inode_on_disk = None
            if my_inode != inode_on_disk:
                # File was already deleted. Close it and try to open it again.
                continue

            try:
                yield
            finally:
                # Whether the body succeeded or not, unlink and close the file.
                os.unlink(lock_path)

            return
        finally:
            f.close()


@contextlib.contextmanager
def transaction(request, sessid=None):
    if not sessid: sessid = get_session_cookie(request)
    if not sessid: raise LoggedOutError('Session cookie not found')

    with lock(request.app, sessid):
        try:
            f = open(get_filename(request, sessid), 'r+b')
        except FileNotFoundError as e:

# Path: aisikl/exceptions.py
# class LoggedOutError(AisiklError):
#     '''Request couldn't be completed because we are no longer logged in.'''


# Path: votrfront/sessions.py
import contextlib
import fcntl
import gzip
import os
import pickle
from aisikl.exceptions import LoggedOutError

            # Lock acquired, but is it still the same file? Compare inodes.
            my_inode = os.fstat(f.fileno()).st_ino
            try:
                inode_on_disk = os.stat(lock_path).st_ino
            except FileNotFoundError:
                inode_on_disk = None
            if my_inode != inode_on_disk:
                # File was already deleted. Close it and try to open it again.
                continue

            try:
                yield
            finally:
                # Whether the body succeeded or not, unlink and close the file.
                os.unlink(lock_path)

            return
        finally:
            f.close()


@contextlib.contextmanager
def transaction(request, sessid=None):
    if not sessid: sessid = get_session_cookie(request)
    if not sessid: raise LoggedOutError('Session cookie not found')

    with lock(request.app, sessid):
        try:
            f = open(get_filename(request, sessid), 'r+b')
        except FileNotFoundError as e:

            raise LoggedOutError('Votr session does not exist') from e