{"action":"created","comment":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/70798876","id":70798876,"diff_hunk":"@@ -0,0 +1,95 @@\n+# This program is free software; you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation; either version 2 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n+#\n+# See LICENSE for more details.\n+#\n+# Copyright: Red Hat Inc. 2016\n+# Author: Amador Pahim <apahim@redhat.com>\n+\n+\n+import errno\n+import os\n+import time\n+\n+\n+class AlreadyLocked(Exception):\n+    pass\n+\n+\n+class LockFailed(Exception):\n+    pass\n+\n+\n+class LockFile(object):\n+    \"\"\"\n+    Creates a lock for a file.\n+\n+    If the lock file already exists and it contains the current process\n+    pid in it, we wait until the timeout for the lock to be released,\n+    raising an AlreadyLocked exception when the timeout is reached.\n+\n+    If the lock file already exists and it contains a pid of another\n+    running process, we raise an NotMyLock exception.\n+\n+    If the lock file exists and it has no running processes pid in it,\n+    we try to clean the file and acquire the lock.\n+    \"\"\"\n+    def __init__(self, filename):\n+        self.filename = '%s.lock' % filename\n+        self.pid = str(os.getpid())\n+        self.locked = False\n+\n+    def acquire(self):\n+        flags = os.O_CREAT | os.O_EXCL | os.O_WRONLY\n+        timeout = time.time() + 1","path":"avocado/utils/filelock.py","position":50,"original_position":50,"commit_id":"0e350666aa2ebe7e6c423bbdf0628675e2d4470c","original_commit_id":"d0ce0b3a00c11a71e490677eb76a6ea58540ef61","user":{"login":"apahim","id":4717757,"avatar_url":"https://avatars.githubusercontent.com/u/4717757?v=3","gravatar_id":"","url":"https://api.github.com/users/apahim","html_url":"https://github.com/apahim","followers_url":"https://api.github.com/users/apahim/followers","following_url":"https://api.github.com/users/apahim/following{/other_user}","gists_url":"https://api.github.com/users/apahim/gists{/gist_id}","starred_url":"https://api.github.com/users/apahim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apahim/subscriptions","organizations_url":"https://api.github.com/users/apahim/orgs","repos_url":"https://api.github.com/users/apahim/repos","events_url":"https://api.github.com/users/apahim/events{/privacy}","received_events_url":"https://api.github.com/users/apahim/received_events","type":"User","site_admin":false},"body":"Make timeout defaults to `0` and make it configurable.","created_at":"2016-07-14T12:51:07Z","updated_at":"2016-07-14T12:51:07Z","html_url":"https://github.com/avocado-framework/avocado/pull/1304#discussion_r70798876","pull_request_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1304","_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/70798876"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/1304#discussion_r70798876"},"pull_request":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1304"}}},"pull_request":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1304","id":77419192,"html_url":"https://github.com/avocado-framework/avocado/pull/1304","diff_url":"https://github.com/avocado-framework/avocado/pull/1304.diff","patch_url":"https://github.com/avocado-framework/avocado/pull/1304.patch","issue_url":"https://api.github.com/repos/avocado-framework/avocado/issues/1304","number":1304,"state":"open","locked":false,"title":"Asset fetcher improvements [v2]","user":{"login":"apahim","id":4717757,"avatar_url":"https://avatars.githubusercontent.com/u/4717757?v=3","gravatar_id":"","url":"https://api.github.com/users/apahim","html_url":"https://github.com/apahim","followers_url":"https://api.github.com/users/apahim/followers","following_url":"https://api.github.com/users/apahim/following{/other_user}","gists_url":"https://api.github.com/users/apahim/gists{/gist_id}","starred_url":"https://api.github.com/users/apahim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apahim/subscriptions","organizations_url":"https://api.github.com/users/apahim/orgs","repos_url":"https://api.github.com/users/apahim/repos","events_url":"https://api.github.com/users/apahim/events{/privacy}","received_events_url":"https://api.github.com/users/apahim/received_events","type":"User","site_admin":false},"body":"v2:\r\n-  Introduce the file locker utility.\r\n-  Asset fetcher improvements:\r\n - Use the avocado.utils.filelock to avoid race conditions:\r\n - Drop EnviromentError exceptions on cache miss.\r\n - Clean excessive debug messages.\r\n - Unify hashfile for any algorithm.\r\n - Improve hashfile control.\r\n\r\nv1: #1299 \r\nPreliminary work, intended to collect feedback. No need to look there ;)\r\n\r\nReference: https://trello.com/c/NeFPMkZY\r\nReference: https://trello.com/c/OWCprQpd","created_at":"2016-07-14T08:41:24Z","updated_at":"2016-07-14T12:51:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70d4a4ed094bdbd1a3aa951e1592a8a9a21f003a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1304/commits","review_comments_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1304/comments","review_comment_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments{/number}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/issues/1304/comments","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/0e350666aa2ebe7e6c423bbdf0628675e2d4470c","head":{"label":"apahim:asset_improvements_v2","ref":"asset_improvements_v2","sha":"0e350666aa2ebe7e6c423bbdf0628675e2d4470c","user":{"login":"apahim","id":4717757,"avatar_url":"https://avatars.githubusercontent.com/u/4717757?v=3","gravatar_id":"","url":"https://api.github.com/users/apahim","html_url":"https://github.com/apahim","followers_url":"https://api.github.com/users/apahim/followers","following_url":"https://api.github.com/users/apahim/following{/other_user}","gists_url":"https://api.github.com/users/apahim/gists{/gist_id}","starred_url":"https://api.github.com/users/apahim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apahim/subscriptions","organizations_url":"https://api.github.com/users/apahim/orgs","repos_url":"https://api.github.com/users/apahim/repos","events_url":"https://api.github.com/users/apahim/events{/privacy}","received_events_url":"https://api.github.com/users/apahim/received_events","type":"User","site_admin":false},"repo":{"id":44574830,"name":"avocado","full_name":"apahim/avocado","owner":{"login":"apahim","id":4717757,"avatar_url":"https://avatars.githubusercontent.com/u/4717757?v=3","gravatar_id":"","url":"https://api.github.com/users/apahim","html_url":"https://github.com/apahim","followers_url":"https://api.github.com/users/apahim/followers","following_url":"https://api.github.com/users/apahim/following{/other_user}","gists_url":"https://api.github.com/users/apahim/gists{/gist_id}","starred_url":"https://api.github.com/users/apahim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apahim/subscriptions","organizations_url":"https://api.github.com/users/apahim/orgs","repos_url":"https://api.github.com/users/apahim/repos","events_url":"https://api.github.com/users/apahim/events{/privacy}","received_events_url":"https://api.github.com/users/apahim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/apahim/avocado","description":"Avocado Test Framework","fork":true,"url":"https://api.github.com/repos/apahim/avocado","forks_url":"https://api.github.com/repos/apahim/avocado/forks","keys_url":"https://api.github.com/repos/apahim/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apahim/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apahim/avocado/teams","hooks_url":"https://api.github.com/repos/apahim/avocado/hooks","issue_events_url":"https://api.github.com/repos/apahim/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/apahim/avocado/events","assignees_url":"https://api.github.com/repos/apahim/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/apahim/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/apahim/avocado/tags","blobs_url":"https://api.github.com/repos/apahim/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apahim/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apahim/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/apahim/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apahim/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/apahim/avocado/languages","stargazers_url":"https://api.github.com/repos/apahim/avocado/stargazers","contributors_url":"https://api.github.com/repos/apahim/avocado/contributors","subscribers_url":"https://api.github.com/repos/apahim/avocado/subscribers","subscription_url":"https://api.github.com/repos/apahim/avocado/subscription","commits_url":"https://api.github.com/repos/apahim/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/apahim/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/apahim/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/apahim/avocado/issues/comments{/number}","contents_url":"https://api.github.com/repos/apahim/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/apahim/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apahim/avocado/merges","archive_url":"https://api.github.com/repos/apahim/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apahim/avocado/downloads","issues_url":"https://api.github.com/repos/apahim/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/apahim/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/apahim/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/apahim/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apahim/avocado/labels{/name}","releases_url":"https://api.github.com/repos/apahim/avocado/releases{/id}","deployments_url":"https://api.github.com/repos/apahim/avocado/deployments","created_at":"2015-10-20T01:37:56Z","updated_at":"2016-01-12T16:29:34Z","pushed_at":"2016-07-14T09:55:54Z","git_url":"git://github.com/apahim/avocado.git","ssh_url":"git@github.com:apahim/avocado.git","clone_url":"https://github.com/apahim/avocado.git","svn_url":"https://github.com/apahim/avocado","homepage":"http://avocado-framework.github.io/","size":8919,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"avocado-framework:master","ref":"master","sha":"59758cba306b91cdb5672005ab9938fae346b08e","user":{"login":"avocado-framework","id":7245719,"avatar_url":"https://avatars.githubusercontent.com/u/7245719?v=3","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":17449498,"name":"avocado","full_name":"avocado-framework/avocado","owner":{"login":"avocado-framework","id":7245719,"avatar_url":"https://avatars.githubusercontent.com/u/7245719?v=3","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/avocado-framework/avocado","description":"Avocado Test Framework","fork":false,"url":"https://api.github.com/repos/avocado-framework/avocado","forks_url":"https://api.github.com/repos/avocado-framework/avocado/forks","keys_url":"https://api.github.com/repos/avocado-framework/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avocado-framework/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avocado-framework/avocado/teams","hooks_url":"https://api.github.com/repos/avocado-framework/avocado/hooks","issue_events_url":"https://api.github.com/repos/avocado-framework/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/avocado-framework/avocado/events","assignees_url":"https://api.github.com/repos/avocado-framework/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/avocado-framework/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/avocado-framework/avocado/tags","blobs_url":"https://api.github.com/repos/avocado-framework/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avocado-framework/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avocado-framework/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/avocado-framework/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/avocado-framework/avocado/languages","stargazers_url":"https://api.github.com/repos/avocado-framework/avocado/stargazers","contributors_url":"https://api.github.com/repos/avocado-framework/avocado/contributors","subscribers_url":"https://api.github.com/repos/avocado-framework/avocado/subscribers","subscription_url":"https://api.github.com/repos/avocado-framework/avocado/subscription","commits_url":"https://api.github.com/repos/avocado-framework/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/avocado-framework/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/avocado-framework/avocado/issues/comments{/number}","contents_url":"https://api.github.com/repos/avocado-framework/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/avocado-framework/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avocado-framework/avocado/merges","archive_url":"https://api.github.com/repos/avocado-framework/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avocado-framework/avocado/downloads","issues_url":"https://api.github.com/repos/avocado-framework/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/avocado-framework/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/avocado-framework/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/avocado-framework/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avocado-framework/avocado/labels{/name}","releases_url":"https://api.github.com/repos/avocado-framework/avocado/releases{/id}","deployments_url":"https://api.github.com/repos/avocado-framework/avocado/deployments","created_at":"2014-03-05T17:52:27Z","updated_at":"2016-07-09T19:26:09Z","pushed_at":"2016-07-14T12:31:15Z","git_url":"git://github.com/avocado-framework/avocado.git","ssh_url":"git@github.com:avocado-framework/avocado.git","clone_url":"https://github.com/avocado-framework/avocado.git","svn_url":"https://github.com/avocado-framework/avocado","homepage":"http://avocado-framework.github.io/","size":14046,"stargazers_count":48,"watchers_count":48,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":61,"mirror_url":null,"open_issues_count":13,"forks":61,"open_issues":13,"watchers":48,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1304"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/1304"},"issue":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/1304"},"comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/1304/comments"},"review_comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1304/comments"},"review_comment":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1304/commits"},"statuses":{"href":"https://api.github.com/repos/avocado-framework/avocado/statuses/0e350666aa2ebe7e6c423bbdf0628675e2d4470c"}}}}
{"actor":{"display_login":"apahim"}}