{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/41629","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/41629/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/41629/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/41629/events","html_url":"https://github.com/ansible/ansible/pull/41629","id":333089505,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1MzkzMjg0","number":41629,"title":"Add generic file locking feature","user":{"login":"acalm","id":17545952,"node_id":"MDQ6VXNlcjE3NTQ1OTUy","avatar_url":"https://avatars0.githubusercontent.com/u/17545952?v=4","gravatar_id":"","url":"https://api.github.com/users/acalm","html_url":"https://github.com/acalm","followers_url":"https://api.github.com/users/acalm/followers","following_url":"https://api.github.com/users/acalm/following{/other_user}","gists_url":"https://api.github.com/users/acalm/gists{/gist_id}","starred_url":"https://api.github.com/users/acalm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acalm/subscriptions","organizations_url":"https://api.github.com/users/acalm/orgs","repos_url":"https://api.github.com/users/acalm/repos","events_url":"https://api.github.com/users/acalm/events{/privacy}","received_events_url":"https://api.github.com/users/acalm/received_events","type":"User","site_admin":false},"labels":[{"id":947190508,"node_id":"MDU6TGFiZWw5NDcxOTA1MDg=","url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.7","name":"affects_2.7","color":"ededed","default":false},{"id":852590921,"node_id":"MDU6TGFiZWw4NTI1OTA5MjE=","url":"https://api.github.com/repos/ansible/ansible/labels/feature","name":"feature","color":"006b75","default":false},{"id":581543918,"node_id":"MDU6TGFiZWw1ODE1NDM5MTg=","url":"https://api.github.com/repos/ansible/ansible/labels/stale_ci","name":"stale_ci","color":"fef2c0","default":false},{"id":636352796,"node_id":"MDU6TGFiZWw2MzYzNTI3OTY=","url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-17T20:15:01Z","updated_at":"2018-06-29T10:20:19Z","closed_at":"2018-06-29T10:20:19Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/41629","html_url":"https://github.com/ansible/ansible/pull/41629","diff_url":"https://github.com/ansible/ansible/pull/41629.diff","patch_url":"https://github.com/ansible/ansible/pull/41629.patch"},"body":"##### SUMMARY\r\nFixes #29962\r\nThis adds a simple and generic file locking feature through fcntl.flock.\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Feature Pull Request\r\n##### COMPONENT NAME\r\n<!--- Name of the module, plugin, module or task -->\r\nbasic.py\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from \"ansible --version\" between quotes below -->\r\n```\r\nansible 2.7.0.dev0 (29962-feature-file-locking d77e8b36ff) last updated 2018/06/17 21:44:54 (GMT +200)\r\n  config file = None\r\n  configured module search path = ['/home/acalm/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /home/acalm/venv/ansible/lib/python3.6/site-packages/ansible\r\n  executable location = /home/acalm/venv/ansible/bin/ansible\r\n\r\n```\r\n\r\n\r\n##### ADDITIONAL INFORMATION\r\n<!--- Include additional information to help people understand the change here.\r\nFor bugs that don't have a linked bug report, a step-by-step reproduction\r\nof the problem is helpful. -->\r\nCall lock_file() before any actions are performed on file and call unlock_file() when operations are done. lock_file also accepts a timeout, if reached False will be returned.\r\n\r\nThis could be used to solve issues like #30413, also slightly related to #31096, however this PR just provides exclusive access to a given file. Also due to the nature of file locking on Linux, above only works IF all processes accessing the file utilizes flock of course. There's a slight risk of dangling file handlers if a module terminates before managing to call unlock_file, this could potentially be done more safely by using context, but then module(s) potentially using this feature would possibly have to wrap larger parts of their code into a with clause.\r\n\r\n<!--- Paste verbatim command output below, e.g. before and after your change -->\r\n```\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/401314159","html_url":"https://github.com/ansible/ansible/pull/41629#issuecomment-401314159","issue_url":"https://api.github.com/repos/ansible/ansible/issues/41629","id":401314159,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTMxNDE1OQ==","user":{"login":"mkrizek","id":1215518,"node_id":"MDQ6VXNlcjEyMTU1MTg=","avatar_url":"https://avatars2.githubusercontent.com/u/1215518?v=4","gravatar_id":"","url":"https://api.github.com/users/mkrizek","html_url":"https://github.com/mkrizek","followers_url":"https://api.github.com/users/mkrizek/followers","following_url":"https://api.github.com/users/mkrizek/following{/other_user}","gists_url":"https://api.github.com/users/mkrizek/gists{/gist_id}","starred_url":"https://api.github.com/users/mkrizek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkrizek/subscriptions","organizations_url":"https://api.github.com/users/mkrizek/orgs","repos_url":"https://api.github.com/users/mkrizek/repos","events_url":"https://api.github.com/users/mkrizek/events{/privacy}","received_events_url":"https://api.github.com/users/mkrizek/received_events","type":"User","site_admin":false},"created_at":"2018-06-29T10:20:19Z","updated_at":"2018-06-29T10:20:19Z","author_association":"CONTRIBUTOR","body":"Closing as per above."}}
{"actor":{"display_login":"mkrizek"}}