{"action":"closed","number":158,"pull_request":{"url":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls/158","id":67926655,"html_url":"https://github.com/NYPL-Simplified/circulation/pull/158","diff_url":"https://github.com/NYPL-Simplified/circulation/pull/158.diff","patch_url":"https://github.com/NYPL-Simplified/circulation/pull/158.patch","issue_url":"https://api.github.com/repos/NYPL-Simplified/circulation/issues/158","number":158,"state":"closed","locked":false,"title":"Scoped session","user":{"login":"leonardr","id":662474,"avatar_url":"https://avatars.githubusercontent.com/u/662474?v=3","gravatar_id":"","url":"https://api.github.com/users/leonardr","html_url":"https://github.com/leonardr","followers_url":"https://api.github.com/users/leonardr/followers","following_url":"https://api.github.com/users/leonardr/following{/other_user}","gists_url":"https://api.github.com/users/leonardr/gists{/gist_id}","starred_url":"https://api.github.com/users/leonardr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonardr/subscriptions","organizations_url":"https://api.github.com/users/leonardr/orgs","repos_url":"https://api.github.com/users/leonardr/repos","events_url":"https://api.github.com/users/leonardr/events{/privacy}","received_events_url":"https://api.github.com/users/leonardr/received_events","type":"User","site_admin":false},"body":"This branch initializes the CirculationManager object with a scoped session (http://flask-sqlalchemy-session.readthedocs.org/en/v1.1/) which creates a new database session per Flask request. \r\n\r\nThis will allow us to configure uwsgi to spawn multiple threads inside a single worker process. The advantage of that is explained here:\r\n\r\nhttp://stackoverflow.com/questions/20058464/whats-the-advantage-of-running-multiple-threads-per-uwsgi-process\r\n\r\nThis won't help us handle more simultaneous requests (only more workers will do that), EXCEPT in the case when a request gets bogged down in a long-running IO-bound task (such as checking out a book from a slow provider). If that happens, multithreading allows that worker to handle another request while it waits for the IO-bound task to complete.\r\n\r\nThis is a low-cost solution to the problem of long-running IO-bound tasks eating up all the worker processes. The highest-performance solution is to make the circulation manager asynchronous, but after doing a lot of research I think this is incompatible with our use of the SQLAlchemy ORM. \r\n\r\nThe next best-performing solution is to put all the big network-bound patron tasks--checking out books, fulfilling them, putting them on hold, etc. into a database table and fulfil them asynchronously with a Monitor. I think this is a good idea but it's a lot more work than this, and even once that's done this will make the app server more scalable.","created_at":"2016-04-26T17:33:47Z","updated_at":"2016-04-26T18:12:45Z","closed_at":"2016-04-26T18:12:45Z","merged_at":"2016-04-26T18:12:45Z","merge_commit_sha":"5bcff8c7ca49ebf8f97d232549de19c65d55a5be","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls/158/commits","review_comments_url":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls/158/comments","review_comment_url":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NYPL-Simplified/circulation/issues/158/comments","statuses_url":"https://api.github.com/repos/NYPL-Simplified/circulation/statuses/da2f611ee3fedb59f6ef2b20b6dab6e0e66e9a9e","head":{"label":"NYPL-Simplified:scoped-session","ref":"scoped-session","sha":"da2f611ee3fedb59f6ef2b20b6dab6e0e66e9a9e","user":{"login":"NYPL-Simplified","id":16416905,"avatar_url":"https://avatars.githubusercontent.com/u/16416905?v=3","gravatar_id":"","url":"https://api.github.com/users/NYPL-Simplified","html_url":"https://github.com/NYPL-Simplified","followers_url":"https://api.github.com/users/NYPL-Simplified/followers","following_url":"https://api.github.com/users/NYPL-Simplified/following{/other_user}","gists_url":"https://api.github.com/users/NYPL-Simplified/gists{/gist_id}","starred_url":"https://api.github.com/users/NYPL-Simplified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYPL-Simplified/subscriptions","organizations_url":"https://api.github.com/users/NYPL-Simplified/orgs","repos_url":"https://api.github.com/users/NYPL-Simplified/repos","events_url":"https://api.github.com/users/NYPL-Simplified/events{/privacy}","received_events_url":"https://api.github.com/users/NYPL-Simplified/received_events","type":"Organization","site_admin":false},"repo":{"id":27605405,"name":"circulation","full_name":"NYPL-Simplified/circulation","owner":{"login":"NYPL-Simplified","id":16416905,"avatar_url":"https://avatars.githubusercontent.com/u/16416905?v=3","gravatar_id":"","url":"https://api.github.com/users/NYPL-Simplified","html_url":"https://github.com/NYPL-Simplified","followers_url":"https://api.github.com/users/NYPL-Simplified/followers","following_url":"https://api.github.com/users/NYPL-Simplified/following{/other_user}","gists_url":"https://api.github.com/users/NYPL-Simplified/gists{/gist_id}","starred_url":"https://api.github.com/users/NYPL-Simplified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYPL-Simplified/subscriptions","organizations_url":"https://api.github.com/users/NYPL-Simplified/orgs","repos_url":"https://api.github.com/users/NYPL-Simplified/repos","events_url":"https://api.github.com/users/NYPL-Simplified/events{/privacy}","received_events_url":"https://api.github.com/users/NYPL-Simplified/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NYPL-Simplified/circulation","description":"Circulation manager for Library Simplified","fork":false,"url":"https://api.github.com/repos/NYPL-Simplified/circulation","forks_url":"https://api.github.com/repos/NYPL-Simplified/circulation/forks","keys_url":"https://api.github.com/repos/NYPL-Simplified/circulation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NYPL-Simplified/circulation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NYPL-Simplified/circulation/teams","hooks_url":"https://api.github.com/repos/NYPL-Simplified/circulation/hooks","issue_events_url":"https://api.github.com/repos/NYPL-Simplified/circulation/issues/events{/number}","events_url":"https://api.github.com/repos/NYPL-Simplified/circulation/events","assignees_url":"https://api.github.com/repos/NYPL-Simplified/circulation/assignees{/user}","branches_url":"https://api.github.com/repos/NYPL-Simplified/circulation/branches{/branch}","tags_url":"https://api.github.com/repos/NYPL-Simplified/circulation/tags","blobs_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/refs{/sha}","trees_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NYPL-Simplified/circulation/statuses/{sha}","languages_url":"https://api.github.com/repos/NYPL-Simplified/circulation/languages","stargazers_url":"https://api.github.com/repos/NYPL-Simplified/circulation/stargazers","contributors_url":"https://api.github.com/repos/NYPL-Simplified/circulation/contributors","subscribers_url":"https://api.github.com/repos/NYPL-Simplified/circulation/subscribers","subscription_url":"https://api.github.com/repos/NYPL-Simplified/circulation/subscription","commits_url":"https://api.github.com/repos/NYPL-Simplified/circulation/commits{/sha}","git_commits_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/commits{/sha}","comments_url":"https://api.github.com/repos/NYPL-Simplified/circulation/comments{/number}","issue_comment_url":"https://api.github.com/repos/NYPL-Simplified/circulation/issues/comments{/number}","contents_url":"https://api.github.com/repos/NYPL-Simplified/circulation/contents/{+path}","compare_url":"https://api.github.com/repos/NYPL-Simplified/circulation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NYPL-Simplified/circulation/merges","archive_url":"https://api.github.com/repos/NYPL-Simplified/circulation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NYPL-Simplified/circulation/downloads","issues_url":"https://api.github.com/repos/NYPL-Simplified/circulation/issues{/number}","pulls_url":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls{/number}","milestones_url":"https://api.github.com/repos/NYPL-Simplified/circulation/milestones{/number}","notifications_url":"https://api.github.com/repos/NYPL-Simplified/circulation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NYPL-Simplified/circulation/labels{/name}","releases_url":"https://api.github.com/repos/NYPL-Simplified/circulation/releases{/id}","deployments_url":"https://api.github.com/repos/NYPL-Simplified/circulation/deployments","created_at":"2014-12-05T18:53:04Z","updated_at":"2016-01-25T15:36:03Z","pushed_at":"2016-04-26T18:12:45Z","git_url":"git://github.com/NYPL-Simplified/circulation.git","ssh_url":"git@github.com:NYPL-Simplified/circulation.git","clone_url":"https://github.com/NYPL-Simplified/circulation.git","svn_url":"https://github.com/NYPL-Simplified/circulation","homepage":null,"size":890,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"base":{"label":"NYPL-Simplified:master","ref":"master","sha":"9564e75b4f31c6f7d103928fa1aad40273f3c417","user":{"login":"NYPL-Simplified","id":16416905,"avatar_url":"https://avatars.githubusercontent.com/u/16416905?v=3","gravatar_id":"","url":"https://api.github.com/users/NYPL-Simplified","html_url":"https://github.com/NYPL-Simplified","followers_url":"https://api.github.com/users/NYPL-Simplified/followers","following_url":"https://api.github.com/users/NYPL-Simplified/following{/other_user}","gists_url":"https://api.github.com/users/NYPL-Simplified/gists{/gist_id}","starred_url":"https://api.github.com/users/NYPL-Simplified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYPL-Simplified/subscriptions","organizations_url":"https://api.github.com/users/NYPL-Simplified/orgs","repos_url":"https://api.github.com/users/NYPL-Simplified/repos","events_url":"https://api.github.com/users/NYPL-Simplified/events{/privacy}","received_events_url":"https://api.github.com/users/NYPL-Simplified/received_events","type":"Organization","site_admin":false},"repo":{"id":27605405,"name":"circulation","full_name":"NYPL-Simplified/circulation","owner":{"login":"NYPL-Simplified","id":16416905,"avatar_url":"https://avatars.githubusercontent.com/u/16416905?v=3","gravatar_id":"","url":"https://api.github.com/users/NYPL-Simplified","html_url":"https://github.com/NYPL-Simplified","followers_url":"https://api.github.com/users/NYPL-Simplified/followers","following_url":"https://api.github.com/users/NYPL-Simplified/following{/other_user}","gists_url":"https://api.github.com/users/NYPL-Simplified/gists{/gist_id}","starred_url":"https://api.github.com/users/NYPL-Simplified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYPL-Simplified/subscriptions","organizations_url":"https://api.github.com/users/NYPL-Simplified/orgs","repos_url":"https://api.github.com/users/NYPL-Simplified/repos","events_url":"https://api.github.com/users/NYPL-Simplified/events{/privacy}","received_events_url":"https://api.github.com/users/NYPL-Simplified/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NYPL-Simplified/circulation","description":"Circulation manager for Library Simplified","fork":false,"url":"https://api.github.com/repos/NYPL-Simplified/circulation","forks_url":"https://api.github.com/repos/NYPL-Simplified/circulation/forks","keys_url":"https://api.github.com/repos/NYPL-Simplified/circulation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NYPL-Simplified/circulation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NYPL-Simplified/circulation/teams","hooks_url":"https://api.github.com/repos/NYPL-Simplified/circulation/hooks","issue_events_url":"https://api.github.com/repos/NYPL-Simplified/circulation/issues/events{/number}","events_url":"https://api.github.com/repos/NYPL-Simplified/circulation/events","assignees_url":"https://api.github.com/repos/NYPL-Simplified/circulation/assignees{/user}","branches_url":"https://api.github.com/repos/NYPL-Simplified/circulation/branches{/branch}","tags_url":"https://api.github.com/repos/NYPL-Simplified/circulation/tags","blobs_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/refs{/sha}","trees_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NYPL-Simplified/circulation/statuses/{sha}","languages_url":"https://api.github.com/repos/NYPL-Simplified/circulation/languages","stargazers_url":"https://api.github.com/repos/NYPL-Simplified/circulation/stargazers","contributors_url":"https://api.github.com/repos/NYPL-Simplified/circulation/contributors","subscribers_url":"https://api.github.com/repos/NYPL-Simplified/circulation/subscribers","subscription_url":"https://api.github.com/repos/NYPL-Simplified/circulation/subscription","commits_url":"https://api.github.com/repos/NYPL-Simplified/circulation/commits{/sha}","git_commits_url":"https://api.github.com/repos/NYPL-Simplified/circulation/git/commits{/sha}","comments_url":"https://api.github.com/repos/NYPL-Simplified/circulation/comments{/number}","issue_comment_url":"https://api.github.com/repos/NYPL-Simplified/circulation/issues/comments{/number}","contents_url":"https://api.github.com/repos/NYPL-Simplified/circulation/contents/{+path}","compare_url":"https://api.github.com/repos/NYPL-Simplified/circulation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NYPL-Simplified/circulation/merges","archive_url":"https://api.github.com/repos/NYPL-Simplified/circulation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NYPL-Simplified/circulation/downloads","issues_url":"https://api.github.com/repos/NYPL-Simplified/circulation/issues{/number}","pulls_url":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls{/number}","milestones_url":"https://api.github.com/repos/NYPL-Simplified/circulation/milestones{/number}","notifications_url":"https://api.github.com/repos/NYPL-Simplified/circulation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NYPL-Simplified/circulation/labels{/name}","releases_url":"https://api.github.com/repos/NYPL-Simplified/circulation/releases{/id}","deployments_url":"https://api.github.com/repos/NYPL-Simplified/circulation/deployments","created_at":"2014-12-05T18:53:04Z","updated_at":"2016-01-25T15:36:03Z","pushed_at":"2016-04-26T18:12:45Z","git_url":"git://github.com/NYPL-Simplified/circulation.git","ssh_url":"git@github.com:NYPL-Simplified/circulation.git","clone_url":"https://github.com/NYPL-Simplified/circulation.git","svn_url":"https://github.com/NYPL-Simplified/circulation","homepage":null,"size":890,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls/158"},"html":{"href":"https://github.com/NYPL-Simplified/circulation/pull/158"},"issue":{"href":"https://api.github.com/repos/NYPL-Simplified/circulation/issues/158"},"comments":{"href":"https://api.github.com/repos/NYPL-Simplified/circulation/issues/158/comments"},"review_comments":{"href":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls/158/comments"},"review_comment":{"href":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NYPL-Simplified/circulation/pulls/158/commits"},"statuses":{"href":"https://api.github.com/repos/NYPL-Simplified/circulation/statuses/da2f611ee3fedb59f6ef2b20b6dab6e0e66e9a9e"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"leonardr","id":662474,"avatar_url":"https://avatars.githubusercontent.com/u/662474?v=3","gravatar_id":"","url":"https://api.github.com/users/leonardr","html_url":"https://github.com/leonardr","followers_url":"https://api.github.com/users/leonardr/followers","following_url":"https://api.github.com/users/leonardr/following{/other_user}","gists_url":"https://api.github.com/users/leonardr/gists{/gist_id}","starred_url":"https://api.github.com/users/leonardr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonardr/subscriptions","organizations_url":"https://api.github.com/users/leonardr/orgs","repos_url":"https://api.github.com/users/leonardr/repos","events_url":"https://api.github.com/users/leonardr/events{/privacy}","received_events_url":"https://api.github.com/users/leonardr/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"commits":3,"additions":12,"deletions":6,"changed_files":4}}