{"action":"created","issue":{"url":"https://api.github.com/repos/KanoComputing/kano-settings/issues/336","labels_url":"https://api.github.com/repos/KanoComputing/kano-settings/issues/336/labels{/name}","comments_url":"https://api.github.com/repos/KanoComputing/kano-settings/issues/336/comments","events_url":"https://api.github.com/repos/KanoComputing/kano-settings/issues/336/events","html_url":"https://github.com/KanoComputing/kano-settings/pull/336","id":126893333,"number":336,"title":"Config locking","user":{"login":"Ealdwulf","id":37270,"avatar_url":"https://avatars.githubusercontent.com/u/37270?v=3","gravatar_id":"","url":"https://api.github.com/users/Ealdwulf","html_url":"https://github.com/Ealdwulf","followers_url":"https://api.github.com/users/Ealdwulf/followers","following_url":"https://api.github.com/users/Ealdwulf/following{/other_user}","gists_url":"https://api.github.com/users/Ealdwulf/gists{/gist_id}","starred_url":"https://api.github.com/users/Ealdwulf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ealdwulf/subscriptions","organizations_url":"https://api.github.com/users/Ealdwulf/orgs","repos_url":"https://api.github.com/users/Ealdwulf/repos","events_url":"https://api.github.com/users/Ealdwulf/events{/privacy}","received_events_url":"https://api.github.com/users/Ealdwulf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-01-15T15:20:50Z","updated_at":"2016-01-15T16:50:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/KanoComputing/kano-settings/pulls/336","html_url":"https://github.com/KanoComputing/kano-settings/pull/336","diff_url":"https://github.com/KanoComputing/kano-settings/pull/336.diff","patch_url":"https://github.com/KanoComputing/kano-settings/pull/336.patch"},"body":"This PR changes the settings API to be transactional, and changes the settings tools to use it.\r\n\r\nAll changes are applied to temporary file in `/boot`, which is moved into place at the end. This will hopefullly prevent the 'empty config file' problem.\r\n\r\nAll the functions which write  to `/boot/config.txt` will no longer take effect until a call to end_config_transaction(). This includes things like `safe_mode_restore_config`as well as the more obvious ones.  Note that read functions as well as write functions start a transaction. During a transaction, a lock is held so any access by other processes will wait (for up to 5 seconds) and then time out. This wait is in case the boot scripts happen to run at the same time.\r\n\r\n\r\nThis is a bit a bit complicated so APIs used externally to  the kano-settings repo  do an entire transaction. Fortunately there are not many of these. So while some scripts use `set_config_value` and the new `end_config_transaction`, these are ones that live in the kano-settings repo (eg kano-settings-onboot). For this purpose I've moved the config setting in kano-init into a new API function kano_settings.default.set_default_config(), and made the one API used in kano-init-flow (`write_overscan values`) terminate its transaction, and similarly `is_overscan()` which is used by kano-video also terminates its transaction.\r\n\r\n@skarbat @pazdera @convolu @tombettany "},"comment":{"url":"https://api.github.com/repos/KanoComputing/kano-settings/issues/comments/172013146","html_url":"https://github.com/KanoComputing/kano-settings/pull/336#issuecomment-172013146","issue_url":"https://api.github.com/repos/KanoComputing/kano-settings/issues/336","id":172013146,"user":{"login":"Ealdwulf","id":37270,"avatar_url":"https://avatars.githubusercontent.com/u/37270?v=3","gravatar_id":"","url":"https://api.github.com/users/Ealdwulf","html_url":"https://github.com/Ealdwulf","followers_url":"https://api.github.com/users/Ealdwulf/followers","following_url":"https://api.github.com/users/Ealdwulf/following{/other_user}","gists_url":"https://api.github.com/users/Ealdwulf/gists{/gist_id}","starred_url":"https://api.github.com/users/Ealdwulf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ealdwulf/subscriptions","organizations_url":"https://api.github.com/users/Ealdwulf/orgs","repos_url":"https://api.github.com/users/Ealdwulf/repos","events_url":"https://api.github.com/users/Ealdwulf/events{/privacy}","received_events_url":"https://api.github.com/users/Ealdwulf/received_events","type":"User","site_admin":false},"created_at":"2016-01-15T16:50:12Z","updated_at":"2016-01-15T16:50:12Z","body":"@pazdera At the moment it will silently not write back any changes. It won't leave the file locked, as linux will close the lock file when the process ends. Do you think we should have an `atexit` entry to close the transaction as @convolu suggests? Or alternatively, an `atexit` entry that just complains if there is an open transaction.\r\n"}}