# Path: soap/common/cache.py
# def invalidate_cache():
#     from soap import logger
#     from soap.common.parallel import pool
#     process_invalidate_cache()
#     pool.invalidate_cache()
#     logger.info('Cache invalidated.')


import copy
from contextlib import contextmanager
from soap.common.cache import invalidate_cache


class _Context(dict):
    """
    _Context, a dictionary subclass with dot syntax and snapshot support.
    """
    def __init__(self, dictionary=None, **kwargs):
        super().__init__()
        if dictionary:
            kwargs.update(dictionary)
        kwargs = {k: self._cast_dict(v) for k, v in kwargs.items()}
        with self.no_invalidate_cache():
            for k, v in kwargs.items():
                self.__setattr__(k, v)

    @contextmanager
    def no_invalidate_cache(self):
        super().__setattr__('_invalidate_cache', False)
        yield
        super().__delattr__('_invalidate_cache')

    def __setattr__(self, key, value):
        hook = getattr(self, key + '_hook', lambda v: v)
        value = hook(value)
        if key != '_snapshot':
            value = self._cast_dict(value)
        old_value = self.get(key)
        self[key] = value
        if getattr(self, '_invalidate_cache', True):
            if old_value != value:

# Path: soap/common/cache.py
# def invalidate_cache():
#     from soap import logger
#     from soap.common.parallel import pool
#     process_invalidate_cache()
#     pool.invalidate_cache()
#     logger.info('Cache invalidated.')


# Path: soap/context/base.py
import copy
from contextlib import contextmanager
from soap.common.cache import invalidate_cache



class _Context(dict):
    """
    _Context, a dictionary subclass with dot syntax and snapshot support.
    """
    def __init__(self, dictionary=None, **kwargs):
        super().__init__()
        if dictionary:
            kwargs.update(dictionary)
        kwargs = {k: self._cast_dict(v) for k, v in kwargs.items()}
        with self.no_invalidate_cache():
            for k, v in kwargs.items():
                self.__setattr__(k, v)

    @contextmanager
    def no_invalidate_cache(self):
        super().__setattr__('_invalidate_cache', False)
        yield
        super().__delattr__('_invalidate_cache')

    def __setattr__(self, key, value):
        hook = getattr(self, key + '_hook', lambda v: v)
        value = hook(value)
        if key != '_snapshot':
            value = self._cast_dict(value)
        old_value = self.get(key)
        self[key] = value
        if getattr(self, '_invalidate_cache', True):
            if old_value != value:

                invalidate_cache()