{"action":"created","comment":{"url":"https://api.github.com/repos/artefactual/archivematica/pulls/comments/41317037","id":41317037,"diff_hunk":"@@ -200,3 +200,21 @@ def create_structured_directory(basepath, manual_normalization=False, printing=F\n     create_directories(REQUIRED_DIRECTORIES, basepath=basepath, printing=printing)\n     if manual_normalization:\n         create_directories(MANUAL_NORMALIZATION_DIRECTORIES, basepath=basepath, printing=printing)\n+\n+\n+def close_db_connections(fn):\n+    \"\"\"\n+    Decorator to wrap a threaded function in a try-catch ensuring that the\n+    database connections are closed if unrecoverable errors have occurred or if\n+    it outlived its maximum age.\n+\n+    Similar to Django's behavior within HTTP request cycles.\n+    \"\"\"\n+    def wrapped(*args,  **kwargs):\n+        from django.db import close_old_connections","path":"src/archivematicaCommon/lib/archivematicaFunctions.py","position":15,"original_position":15,"commit_id":"056b29cdfa517bf21b1eea92d2e0a911df7d7978","original_commit_id":"056b29cdfa517bf21b1eea92d2e0a911df7d7978","user":{"login":"sevein","id":606459,"avatar_url":"https://avatars.githubusercontent.com/u/606459?v=3","gravatar_id":"","url":"https://api.github.com/users/sevein","html_url":"https://github.com/sevein","followers_url":"https://api.github.com/users/sevein/followers","following_url":"https://api.github.com/users/sevein/following{/other_user}","gists_url":"https://api.github.com/users/sevein/gists{/gist_id}","starred_url":"https://api.github.com/users/sevein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sevein/subscriptions","organizations_url":"https://api.github.com/users/sevein/orgs","repos_url":"https://api.github.com/users/sevein/repos","events_url":"https://api.github.com/users/sevein/events{/privacy}","received_events_url":"https://api.github.com/users/sevein/received_events","type":"User","site_admin":false},"body":"That was intentional because I was trying to make sure that the module is not being cached by Python across multiple threads... but maybe that's going to happen regardless where the import statement is? I'll dig into it and see if I can put the import in the expected place.","created_at":"2015-10-06T20:25:54Z","updated_at":"2015-10-06T20:25:54Z","html_url":"https://github.com/artefactual/archivematica/pull/304#discussion_r41317037","pull_request_url":"https://api.github.com/repos/artefactual/archivematica/pulls/304","_links":{"self":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/comments/41317037"},"html":{"href":"https://github.com/artefactual/archivematica/pull/304#discussion_r41317037"},"pull_request":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/304"}}},"pull_request":{"url":"https://api.github.com/repos/artefactual/archivematica/pulls/304","id":46949107,"html_url":"https://github.com/artefactual/archivematica/pull/304","diff_url":"https://github.com/artefactual/archivematica/pull/304.diff","patch_url":"https://github.com/artefactual/archivematica/pull/304.patch","issue_url":"https://api.github.com/repos/artefactual/archivematica/issues/304","number":304,"state":"open","locked":false,"title":"Close unusable database connections, refs #9021","user":{"login":"sevein","id":606459,"avatar_url":"https://avatars.githubusercontent.com/u/606459?v=3","gravatar_id":"","url":"https://api.github.com/users/sevein","html_url":"https://github.com/sevein","followers_url":"https://api.github.com/users/sevein/followers","following_url":"https://api.github.com/users/sevein/following{/other_user}","gists_url":"https://api.github.com/users/sevein/gists{/gist_id}","starred_url":"https://api.github.com/users/sevein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sevein/subscriptions","organizations_url":"https://api.github.com/users/sevein/orgs","repos_url":"https://api.github.com/users/sevein/repos","events_url":"https://api.github.com/users/sevein/events{/privacy}","received_events_url":"https://api.github.com/users/sevein/received_events","type":"User","site_admin":false},"body":"Wrap threaded functions to ensure that their database connections are only\r\nrecycled if they haven't outlived its maximum age or are in a recoverable\r\nstate, like Django does before and after HTTP requests.\r\n\r\nIt relies on `BaseDatabaseWrapper.close_if_unusable_or_obsolete()` in\r\n`django.db.backends.base`.","created_at":"2015-10-06T19:51:13Z","updated_at":"2015-10-06T20:25:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87a90365ce5f2b35af52762cd2ad11228ee2333b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/artefactual/archivematica/pulls/304/commits","review_comments_url":"https://api.github.com/repos/artefactual/archivematica/pulls/304/comments","review_comment_url":"https://api.github.com/repos/artefactual/archivematica/pulls/comments{/number}","comments_url":"https://api.github.com/repos/artefactual/archivematica/issues/304/comments","statuses_url":"https://api.github.com/repos/artefactual/archivematica/statuses/056b29cdfa517bf21b1eea92d2e0a911df7d7978","head":{"label":"artefactual:dev/issue-9021-mysql-gone-away","ref":"dev/issue-9021-mysql-gone-away","sha":"056b29cdfa517bf21b1eea92d2e0a911df7d7978","user":{"login":"artefactual","id":1163545,"avatar_url":"https://avatars.githubusercontent.com/u/1163545?v=3","gravatar_id":"","url":"https://api.github.com/users/artefactual","html_url":"https://github.com/artefactual","followers_url":"https://api.github.com/users/artefactual/followers","following_url":"https://api.github.com/users/artefactual/following{/other_user}","gists_url":"https://api.github.com/users/artefactual/gists{/gist_id}","starred_url":"https://api.github.com/users/artefactual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artefactual/subscriptions","organizations_url":"https://api.github.com/users/artefactual/orgs","repos_url":"https://api.github.com/users/artefactual/repos","events_url":"https://api.github.com/users/artefactual/events{/privacy}","received_events_url":"https://api.github.com/users/artefactual/received_events","type":"Organization","site_admin":false},"repo":{"id":5811958,"name":"archivematica","full_name":"artefactual/archivematica","owner":{"login":"artefactual","id":1163545,"avatar_url":"https://avatars.githubusercontent.com/u/1163545?v=3","gravatar_id":"","url":"https://api.github.com/users/artefactual","html_url":"https://github.com/artefactual","followers_url":"https://api.github.com/users/artefactual/followers","following_url":"https://api.github.com/users/artefactual/following{/other_user}","gists_url":"https://api.github.com/users/artefactual/gists{/gist_id}","starred_url":"https://api.github.com/users/artefactual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artefactual/subscriptions","organizations_url":"https://api.github.com/users/artefactual/orgs","repos_url":"https://api.github.com/users/artefactual/repos","events_url":"https://api.github.com/users/artefactual/events{/privacy}","received_events_url":"https://api.github.com/users/artefactual/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/artefactual/archivematica","description":"Free and open-source digital preservation system designed to maintain standards-based, long-term access to collections of digital objects.","fork":false,"url":"https://api.github.com/repos/artefactual/archivematica","forks_url":"https://api.github.com/repos/artefactual/archivematica/forks","keys_url":"https://api.github.com/repos/artefactual/archivematica/keys{/key_id}","collaborators_url":"https://api.github.com/repos/artefactual/archivematica/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/artefactual/archivematica/teams","hooks_url":"https://api.github.com/repos/artefactual/archivematica/hooks","issue_events_url":"https://api.github.com/repos/artefactual/archivematica/issues/events{/number}","events_url":"https://api.github.com/repos/artefactual/archivematica/events","assignees_url":"https://api.github.com/repos/artefactual/archivematica/assignees{/user}","branches_url":"https://api.github.com/repos/artefactual/archivematica/branches{/branch}","tags_url":"https://api.github.com/repos/artefactual/archivematica/tags","blobs_url":"https://api.github.com/repos/artefactual/archivematica/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/artefactual/archivematica/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/artefactual/archivematica/git/refs{/sha}","trees_url":"https://api.github.com/repos/artefactual/archivematica/git/trees{/sha}","statuses_url":"https://api.github.com/repos/artefactual/archivematica/statuses/{sha}","languages_url":"https://api.github.com/repos/artefactual/archivematica/languages","stargazers_url":"https://api.github.com/repos/artefactual/archivematica/stargazers","contributors_url":"https://api.github.com/repos/artefactual/archivematica/contributors","subscribers_url":"https://api.github.com/repos/artefactual/archivematica/subscribers","subscription_url":"https://api.github.com/repos/artefactual/archivematica/subscription","commits_url":"https://api.github.com/repos/artefactual/archivematica/commits{/sha}","git_commits_url":"https://api.github.com/repos/artefactual/archivematica/git/commits{/sha}","comments_url":"https://api.github.com/repos/artefactual/archivematica/comments{/number}","issue_comment_url":"https://api.github.com/repos/artefactual/archivematica/issues/comments{/number}","contents_url":"https://api.github.com/repos/artefactual/archivematica/contents/{+path}","compare_url":"https://api.github.com/repos/artefactual/archivematica/compare/{base}...{head}","merges_url":"https://api.github.com/repos/artefactual/archivematica/merges","archive_url":"https://api.github.com/repos/artefactual/archivematica/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/artefactual/archivematica/downloads","issues_url":"https://api.github.com/repos/artefactual/archivematica/issues{/number}","pulls_url":"https://api.github.com/repos/artefactual/archivematica/pulls{/number}","milestones_url":"https://api.github.com/repos/artefactual/archivematica/milestones{/number}","notifications_url":"https://api.github.com/repos/artefactual/archivematica/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/artefactual/archivematica/labels{/name}","releases_url":"https://api.github.com/repos/artefactual/archivematica/releases{/id}","created_at":"2012-09-14T16:43:38Z","updated_at":"2015-09-16T16:02:22Z","pushed_at":"2015-10-06T19:51:13Z","git_url":"git://github.com/artefactual/archivematica.git","ssh_url":"git@github.com:artefactual/archivematica.git","clone_url":"https://github.com/artefactual/archivematica.git","svn_url":"https://github.com/artefactual/archivematica","homepage":"http://www.archivematica.org","size":33715,"stargazers_count":71,"watchers_count":71,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":20,"forks":18,"open_issues":20,"watchers":71,"default_branch":"stable/1.4.x"}},"base":{"label":"artefactual:qa/1.x","ref":"qa/1.x","sha":"de3558b1aa9e8952d460c6121509aa7e8679d1b1","user":{"login":"artefactual","id":1163545,"avatar_url":"https://avatars.githubusercontent.com/u/1163545?v=3","gravatar_id":"","url":"https://api.github.com/users/artefactual","html_url":"https://github.com/artefactual","followers_url":"https://api.github.com/users/artefactual/followers","following_url":"https://api.github.com/users/artefactual/following{/other_user}","gists_url":"https://api.github.com/users/artefactual/gists{/gist_id}","starred_url":"https://api.github.com/users/artefactual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artefactual/subscriptions","organizations_url":"https://api.github.com/users/artefactual/orgs","repos_url":"https://api.github.com/users/artefactual/repos","events_url":"https://api.github.com/users/artefactual/events{/privacy}","received_events_url":"https://api.github.com/users/artefactual/received_events","type":"Organization","site_admin":false},"repo":{"id":5811958,"name":"archivematica","full_name":"artefactual/archivematica","owner":{"login":"artefactual","id":1163545,"avatar_url":"https://avatars.githubusercontent.com/u/1163545?v=3","gravatar_id":"","url":"https://api.github.com/users/artefactual","html_url":"https://github.com/artefactual","followers_url":"https://api.github.com/users/artefactual/followers","following_url":"https://api.github.com/users/artefactual/following{/other_user}","gists_url":"https://api.github.com/users/artefactual/gists{/gist_id}","starred_url":"https://api.github.com/users/artefactual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artefactual/subscriptions","organizations_url":"https://api.github.com/users/artefactual/orgs","repos_url":"https://api.github.com/users/artefactual/repos","events_url":"https://api.github.com/users/artefactual/events{/privacy}","received_events_url":"https://api.github.com/users/artefactual/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/artefactual/archivematica","description":"Free and open-source digital preservation system designed to maintain standards-based, long-term access to collections of digital objects.","fork":false,"url":"https://api.github.com/repos/artefactual/archivematica","forks_url":"https://api.github.com/repos/artefactual/archivematica/forks","keys_url":"https://api.github.com/repos/artefactual/archivematica/keys{/key_id}","collaborators_url":"https://api.github.com/repos/artefactual/archivematica/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/artefactual/archivematica/teams","hooks_url":"https://api.github.com/repos/artefactual/archivematica/hooks","issue_events_url":"https://api.github.com/repos/artefactual/archivematica/issues/events{/number}","events_url":"https://api.github.com/repos/artefactual/archivematica/events","assignees_url":"https://api.github.com/repos/artefactual/archivematica/assignees{/user}","branches_url":"https://api.github.com/repos/artefactual/archivematica/branches{/branch}","tags_url":"https://api.github.com/repos/artefactual/archivematica/tags","blobs_url":"https://api.github.com/repos/artefactual/archivematica/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/artefactual/archivematica/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/artefactual/archivematica/git/refs{/sha}","trees_url":"https://api.github.com/repos/artefactual/archivematica/git/trees{/sha}","statuses_url":"https://api.github.com/repos/artefactual/archivematica/statuses/{sha}","languages_url":"https://api.github.com/repos/artefactual/archivematica/languages","stargazers_url":"https://api.github.com/repos/artefactual/archivematica/stargazers","contributors_url":"https://api.github.com/repos/artefactual/archivematica/contributors","subscribers_url":"https://api.github.com/repos/artefactual/archivematica/subscribers","subscription_url":"https://api.github.com/repos/artefactual/archivematica/subscription","commits_url":"https://api.github.com/repos/artefactual/archivematica/commits{/sha}","git_commits_url":"https://api.github.com/repos/artefactual/archivematica/git/commits{/sha}","comments_url":"https://api.github.com/repos/artefactual/archivematica/comments{/number}","issue_comment_url":"https://api.github.com/repos/artefactual/archivematica/issues/comments{/number}","contents_url":"https://api.github.com/repos/artefactual/archivematica/contents/{+path}","compare_url":"https://api.github.com/repos/artefactual/archivematica/compare/{base}...{head}","merges_url":"https://api.github.com/repos/artefactual/archivematica/merges","archive_url":"https://api.github.com/repos/artefactual/archivematica/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/artefactual/archivematica/downloads","issues_url":"https://api.github.com/repos/artefactual/archivematica/issues{/number}","pulls_url":"https://api.github.com/repos/artefactual/archivematica/pulls{/number}","milestones_url":"https://api.github.com/repos/artefactual/archivematica/milestones{/number}","notifications_url":"https://api.github.com/repos/artefactual/archivematica/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/artefactual/archivematica/labels{/name}","releases_url":"https://api.github.com/repos/artefactual/archivematica/releases{/id}","created_at":"2012-09-14T16:43:38Z","updated_at":"2015-09-16T16:02:22Z","pushed_at":"2015-10-06T19:51:13Z","git_url":"git://github.com/artefactual/archivematica.git","ssh_url":"git@github.com:artefactual/archivematica.git","clone_url":"https://github.com/artefactual/archivematica.git","svn_url":"https://github.com/artefactual/archivematica","homepage":"http://www.archivematica.org","size":33715,"stargazers_count":71,"watchers_count":71,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":20,"forks":18,"open_issues":20,"watchers":71,"default_branch":"stable/1.4.x"}},"_links":{"self":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/304"},"html":{"href":"https://github.com/artefactual/archivematica/pull/304"},"issue":{"href":"https://api.github.com/repos/artefactual/archivematica/issues/304"},"comments":{"href":"https://api.github.com/repos/artefactual/archivematica/issues/304/comments"},"review_comments":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/304/comments"},"review_comment":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/304/commits"},"statuses":{"href":"https://api.github.com/repos/artefactual/archivematica/statuses/056b29cdfa517bf21b1eea92d2e0a911df7d7978"}}}}