from contextlib import contextmanager
from parallels.core import get_logger
from parallels.plesk.source.web import messages

logger = get_logger(__name__)


@contextmanager
def safe_calc_data_size():
    try:
        yield
    except Exception as e:
        logger.exception()
        logger.fdebug(messages.FAILED_CALC_SIZE, error_details=e)

