Edit File: __init__.cpython-37.pyc
B 5/9eW � @ s� d Z ddlmZ ddlZddlmZ ddlmZ ddlm Z ddl mZ ddlm Z d d lmZmZmZ dZdaedd � �ZdS )a, Config for wizard is not like all other our configs, it can be read and modified in multiple processes at the same time, so we should handle that situations correctly. Thus, we must set up exclusive locks for reading and writing and use contextmanager to load config on start and save right after leaving scope and in case of any errors. You can use config like this: with config.acquire_config_access() as config: options = config.get_options(module) or with config.acquire_config_access() as config: options = config.set_state(module, 'failed') � )�absolute_importN)�contextmanager)�Optional)�Config)�MODULES_STATUS_FILE_LOCK)�UnableAcquireLockError� )�BaseConfigError�NoSuchModule�MalformedConfigError)r r r �acquire_config_accessc c s� t d k rt V d S yttd�} W n4 ttfk rT } ztt|�d��W d d }~X Y nX t�| tj � zt � a t V W d zt d kp�t �� W d d a t�| tj� X X d S )N�w)Z error_message) �_config�openr �IOError�OSErrorr �str�fcntlZflockZLOCK_EXr ZsaveZLOCK_UN)Z lock_file�e� r �py/clwizard/config/__init__.pyr G s r )�__doc__Z __future__r r � contextlibr �typingr Zclwizard.config.configr Zclwizard.constantsr Zclwizard.config.exceptionsr � exceptionsr r r �__all__r r r r r r �<module> s