{"action":"created","issue":{"url":"https://api.github.com/repos/benediktschmitt/py-filelock/issues/15","repository_url":"https://api.github.com/repos/benediktschmitt/py-filelock","labels_url":"https://api.github.com/repos/benediktschmitt/py-filelock/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/benediktschmitt/py-filelock/issues/15/comments","events_url":"https://api.github.com/repos/benediktschmitt/py-filelock/issues/15/events","html_url":"https://github.com/benediktschmitt/py-filelock/issues/15","id":196662775,"number":15,"title":"Unexpected and different behaviors on Windows and Linux","user":{"login":"kmdouglass","id":3697676,"avatar_url":"https://avatars.githubusercontent.com/u/3697676?v=3","gravatar_id":"","url":"https://api.github.com/users/kmdouglass","html_url":"https://github.com/kmdouglass","followers_url":"https://api.github.com/users/kmdouglass/followers","following_url":"https://api.github.com/users/kmdouglass/following{/other_user}","gists_url":"https://api.github.com/users/kmdouglass/gists{/gist_id}","starred_url":"https://api.github.com/users/kmdouglass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmdouglass/subscriptions","organizations_url":"https://api.github.com/users/kmdouglass/orgs","repos_url":"https://api.github.com/users/kmdouglass/repos","events_url":"https://api.github.com/users/kmdouglass/events{/privacy}","received_events_url":"https://api.github.com/users/kmdouglass/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-20T12:38:39Z","updated_at":"2016-12-21T15:11:10Z","closed_at":null,"body":"Hi there,\r\nWhen I run the following script, it runs successfully on Linux but fails on Windows 10:\r\n\r\n```python\r\nimport filelock\r\n\r\nlock = filelock.FileLock('test.txt')\r\nwith lock:\r\n    f = open('test.txt', 'w')\r\n    f.write('hello')\r\n    f.close()\r\n```\r\n\r\nThe error on Windows is:\r\n```\r\nPermissionError: [Errno 13] Permission denied\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"lock.py\", line 9, in <module>\r\n    f.close()\r\nPermissionError: [Errno 13] Permission denied\r\n```\r\n\r\n**However**, if I move `f.close()` outside of the context manager, the script successfully runs on Windows and Linux:\r\n\r\n```python\r\nlock = filelock.FileLock('test.txt')\r\nwith lock:\r\n    f = open('test.txt', 'w')\r\n    f.write('hello')\r\nf.close()\r\n```\r\n\r\nWhy exactly must the `f.close()` be placed outside the context manager on Windows, but not on Linux? Is it related to msvcrt.locking()?\r\n\r\nI'm using filelock 2.0.7, Windows 10 (x64) and Debian Jessie (x64)."},"comment":{"url":"https://api.github.com/repos/benediktschmitt/py-filelock/issues/comments/268546290","html_url":"https://github.com/benediktschmitt/py-filelock/issues/15#issuecomment-268546290","issue_url":"https://api.github.com/repos/benediktschmitt/py-filelock/issues/15","id":268546290,"user":{"login":"benediktschmitt","id":5073305,"avatar_url":"https://avatars.githubusercontent.com/u/5073305?v=3","gravatar_id":"","url":"https://api.github.com/users/benediktschmitt","html_url":"https://github.com/benediktschmitt","followers_url":"https://api.github.com/users/benediktschmitt/followers","following_url":"https://api.github.com/users/benediktschmitt/following{/other_user}","gists_url":"https://api.github.com/users/benediktschmitt/gists{/gist_id}","starred_url":"https://api.github.com/users/benediktschmitt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benediktschmitt/subscriptions","organizations_url":"https://api.github.com/users/benediktschmitt/orgs","repos_url":"https://api.github.com/users/benediktschmitt/repos","events_url":"https://api.github.com/users/benediktschmitt/events{/privacy}","received_events_url":"https://api.github.com/users/benediktschmitt/received_events","type":"User","site_admin":false},"created_at":"2016-12-21T15:11:10Z","updated_at":"2016-12-21T15:11:10Z","body":"Hi, \r\nplease take a look at https://github.com/benediktschmitt/py-filelock/issues/9#issuecomment-216296452.\r\n\r\nYou are probably looking for something like https://pypi.python.org/pypi/fasteners or https://pypi.python.org/pypi/lockfile/0.12.2."}}
{"actor":{"display_login":"benediktschmitt"}}