tzM: d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ddl
mZ dd lm
Z
mZmZ d
Zdaed 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')
N)contextmanager)Optional)Config)MODULES_STATUS_FILE_LOCK)UnableAcquireLockError )BaseConfigErrorNoSuchModuleMalformedConfigError)r r
r acquire_config_accessc # K t t V d S t t dd } n7# t t f$ r#}t t
| |d }~ww xY wt j | t j t a t V t d u pt d a t j | t j d S # d a t j | t j w xY w# t d u pt d a t j | t j w # d a t j | t j w xY wxY w)Nwzutf-8)encoding)
error_message)
_configopenr IOErrorOSErrorr strfcntlflockLOCK_EXr saveLOCK_UN) lock_filees py/clwizard/config/__init__.pyr r F s^
B13III W B B B$3q66:::AB
K 5=)))
2((
2tO-w||~~GK 5=11111 GK 5=1111 2tO-w||~~GK 5=1111 GK 5=1111sD . A"AA"D "C" "#DE4
"E,"E4#E11E4)__doc__r
contextlibr typingr clwizard.config.configr clwizard.constantsr clwizard.config.exceptionsr
exceptionsr r
r __all__r r r