{"action":"closed","number":334,"pull_request":{"url":"https://api.github.com/repos/fantix/gino/pulls/334","id":214226309,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0MjI2MzA5","html_url":"https://github.com/fantix/gino/pull/334","diff_url":"https://github.com/fantix/gino/pull/334.diff","patch_url":"https://github.com/fantix/gino/pull/334.patch","issue_url":"https://api.github.com/repos/fantix/gino/issues/334","number":334,"state":"closed","locked":false,"title":"Fixed #313, remove stack when empty","user":{"login":"fantix","id":1751601,"node_id":"MDQ6VXNlcjE3NTE2MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/1751601?v=4","gravatar_id":"","url":"https://api.github.com/users/fantix","html_url":"https://github.com/fantix","followers_url":"https://api.github.com/users/fantix/followers","following_url":"https://api.github.com/users/fantix/following{/other_user}","gists_url":"https://api.github.com/users/fantix/gists{/gist_id}","starred_url":"https://api.github.com/users/fantix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fantix/subscriptions","organizations_url":"https://api.github.com/users/fantix/orgs","repos_url":"https://api.github.com/users/fantix/repos","events_url":"https://api.github.com/users/fantix/events{/privacy}","received_events_url":"https://api.github.com/users/fantix/received_events","type":"User","site_admin":false},"body":"1. I found that it is not possible to use `ctx.reset(token)`, because for now we allow releasing connections in different order, and possibly in different tasks:\r\n\r\n```\r\nasync def task1():\r\n    async with engine.acquire() as conn1:\r\n        loop.create_task(task2())\r\n        await asyncio.sleep(1)\r\n    \r\nasync def task2():\r\n    async with engine.acquire() as conn2:\r\n        await asyncio.sleep(2)\r\n\r\nasyncio.run(task1())\r\n```\r\n\r\nIn this case, both tasks are sharing the same stack, but not reusing each other. The stack was created in `task1`, but cleared out in `task2`. `ContextVar.reset(token)` requires that the given `token` was created in the same context (task), therefore cannot be used in this PR.\r\n\r\n2. There was another approach to create a new empty stack on `acquire()` if the current one is empty. Other than resource waste, there was another reason came to me not to do so, but as writing this PR I cannot remember the reason :sigh","created_at":"2018-09-10T07:54:09Z","updated_at":"2018-09-13T02:12:32Z","closed_at":"2018-09-13T02:12:32Z","merged_at":"2018-09-13T02:12:32Z","merge_commit_sha":"482808484fb737f1685661b8aa99c6c8545ceceb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/fantix/gino/pulls/334/commits","review_comments_url":"https://api.github.com/repos/fantix/gino/pulls/334/comments","review_comment_url":"https://api.github.com/repos/fantix/gino/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fantix/gino/issues/334/comments","statuses_url":"https://api.github.com/repos/fantix/gino/statuses/0a8a19983cc57c948b199160b7fe5cae8add13ed","head":{"label":"fantix:t313","ref":"t313","sha":"0a8a19983cc57c948b199160b7fe5cae8add13ed","user":{"login":"fantix","id":1751601,"node_id":"MDQ6VXNlcjE3NTE2MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/1751601?v=4","gravatar_id":"","url":"https://api.github.com/users/fantix","html_url":"https://github.com/fantix","followers_url":"https://api.github.com/users/fantix/followers","following_url":"https://api.github.com/users/fantix/following{/other_user}","gists_url":"https://api.github.com/users/fantix/gists{/gist_id}","starred_url":"https://api.github.com/users/fantix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fantix/subscriptions","organizations_url":"https://api.github.com/users/fantix/orgs","repos_url":"https://api.github.com/users/fantix/repos","events_url":"https://api.github.com/users/fantix/events{/privacy}","received_events_url":"https://api.github.com/users/fantix/received_events","type":"User","site_admin":false},"repo":{"id":97905816,"node_id":"MDEwOlJlcG9zaXRvcnk5NzkwNTgxNg==","name":"gino","full_name":"fantix/gino","owner":{"login":"fantix","id":1751601,"node_id":"MDQ6VXNlcjE3NTE2MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/1751601?v=4","gravatar_id":"","url":"https://api.github.com/users/fantix","html_url":"https://github.com/fantix","followers_url":"https://api.github.com/users/fantix/followers","following_url":"https://api.github.com/users/fantix/following{/other_user}","gists_url":"https://api.github.com/users/fantix/gists{/gist_id}","starred_url":"https://api.github.com/users/fantix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fantix/subscriptions","organizations_url":"https://api.github.com/users/fantix/orgs","repos_url":"https://api.github.com/users/fantix/repos","events_url":"https://api.github.com/users/fantix/events{/privacy}","received_events_url":"https://api.github.com/users/fantix/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fantix/gino","description":"GINO Is Not ORM - a Python asyncio ORM on SQLAlchemy core.","fork":false,"url":"https://api.github.com/repos/fantix/gino","forks_url":"https://api.github.com/repos/fantix/gino/forks","keys_url":"https://api.github.com/repos/fantix/gino/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fantix/gino/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fantix/gino/teams","hooks_url":"https://api.github.com/repos/fantix/gino/hooks","issue_events_url":"https://api.github.com/repos/fantix/gino/issues/events{/number}","events_url":"https://api.github.com/repos/fantix/gino/events","assignees_url":"https://api.github.com/repos/fantix/gino/assignees{/user}","branches_url":"https://api.github.com/repos/fantix/gino/branches{/branch}","tags_url":"https://api.github.com/repos/fantix/gino/tags","blobs_url":"https://api.github.com/repos/fantix/gino/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fantix/gino/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fantix/gino/git/refs{/sha}","trees_url":"https://api.github.com/repos/fantix/gino/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fantix/gino/statuses/{sha}","languages_url":"https://api.github.com/repos/fantix/gino/languages","stargazers_url":"https://api.github.com/repos/fantix/gino/stargazers","contributors_url":"https://api.github.com/repos/fantix/gino/contributors","subscribers_url":"https://api.github.com/repos/fantix/gino/subscribers","subscription_url":"https://api.github.com/repos/fantix/gino/subscription","commits_url":"https://api.github.com/repos/fantix/gino/commits{/sha}","git_commits_url":"https://api.github.com/repos/fantix/gino/git/commits{/sha}","comments_url":"https://api.github.com/repos/fantix/gino/comments{/number}","issue_comment_url":"https://api.github.com/repos/fantix/gino/issues/comments{/number}","contents_url":"https://api.github.com/repos/fantix/gino/contents/{+path}","compare_url":"https://api.github.com/repos/fantix/gino/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fantix/gino/merges","archive_url":"https://api.github.com/repos/fantix/gino/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fantix/gino/downloads","issues_url":"https://api.github.com/repos/fantix/gino/issues{/number}","pulls_url":"https://api.github.com/repos/fantix/gino/pulls{/number}","milestones_url":"https://api.github.com/repos/fantix/gino/milestones{/number}","notifications_url":"https://api.github.com/repos/fantix/gino/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fantix/gino/labels{/name}","releases_url":"https://api.github.com/repos/fantix/gino/releases{/id}","deployments_url":"https://api.github.com/repos/fantix/gino/deployments","created_at":"2017-07-21T04:27:01Z","updated_at":"2018-09-12T16:14:04Z","pushed_at":"2018-09-13T02:12:32Z","git_url":"git://github.com/fantix/gino.git","ssh_url":"git@github.com:fantix/gino.git","clone_url":"https://github.com/fantix/gino.git","svn_url":"https://github.com/fantix/gino","homepage":"","size":946,"stargazers_count":478,"watchers_count":478,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"archived":false,"open_issues_count":22,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":32,"open_issues":22,"watchers":478,"default_branch":"master"}},"base":{"label":"fantix:master","ref":"master","sha":"64b28c70aaaf5cad3dec0bf3186f36d0955ba478","user":{"login":"fantix","id":1751601,"node_id":"MDQ6VXNlcjE3NTE2MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/1751601?v=4","gravatar_id":"","url":"https://api.github.com/users/fantix","html_url":"https://github.com/fantix","followers_url":"https://api.github.com/users/fantix/followers","following_url":"https://api.github.com/users/fantix/following{/other_user}","gists_url":"https://api.github.com/users/fantix/gists{/gist_id}","starred_url":"https://api.github.com/users/fantix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fantix/subscriptions","organizations_url":"https://api.github.com/users/fantix/orgs","repos_url":"https://api.github.com/users/fantix/repos","events_url":"https://api.github.com/users/fantix/events{/privacy}","received_events_url":"https://api.github.com/users/fantix/received_events","type":"User","site_admin":false},"repo":{"id":97905816,"node_id":"MDEwOlJlcG9zaXRvcnk5NzkwNTgxNg==","name":"gino","full_name":"fantix/gino","owner":{"login":"fantix","id":1751601,"node_id":"MDQ6VXNlcjE3NTE2MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/1751601?v=4","gravatar_id":"","url":"https://api.github.com/users/fantix","html_url":"https://github.com/fantix","followers_url":"https://api.github.com/users/fantix/followers","following_url":"https://api.github.com/users/fantix/following{/other_user}","gists_url":"https://api.github.com/users/fantix/gists{/gist_id}","starred_url":"https://api.github.com/users/fantix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fantix/subscriptions","organizations_url":"https://api.github.com/users/fantix/orgs","repos_url":"https://api.github.com/users/fantix/repos","events_url":"https://api.github.com/users/fantix/events{/privacy}","received_events_url":"https://api.github.com/users/fantix/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fantix/gino","description":"GINO Is Not ORM - a Python asyncio ORM on SQLAlchemy core.","fork":false,"url":"https://api.github.com/repos/fantix/gino","forks_url":"https://api.github.com/repos/fantix/gino/forks","keys_url":"https://api.github.com/repos/fantix/gino/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fantix/gino/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fantix/gino/teams","hooks_url":"https://api.github.com/repos/fantix/gino/hooks","issue_events_url":"https://api.github.com/repos/fantix/gino/issues/events{/number}","events_url":"https://api.github.com/repos/fantix/gino/events","assignees_url":"https://api.github.com/repos/fantix/gino/assignees{/user}","branches_url":"https://api.github.com/repos/fantix/gino/branches{/branch}","tags_url":"https://api.github.com/repos/fantix/gino/tags","blobs_url":"https://api.github.com/repos/fantix/gino/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fantix/gino/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fantix/gino/git/refs{/sha}","trees_url":"https://api.github.com/repos/fantix/gino/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fantix/gino/statuses/{sha}","languages_url":"https://api.github.com/repos/fantix/gino/languages","stargazers_url":"https://api.github.com/repos/fantix/gino/stargazers","contributors_url":"https://api.github.com/repos/fantix/gino/contributors","subscribers_url":"https://api.github.com/repos/fantix/gino/subscribers","subscription_url":"https://api.github.com/repos/fantix/gino/subscription","commits_url":"https://api.github.com/repos/fantix/gino/commits{/sha}","git_commits_url":"https://api.github.com/repos/fantix/gino/git/commits{/sha}","comments_url":"https://api.github.com/repos/fantix/gino/comments{/number}","issue_comment_url":"https://api.github.com/repos/fantix/gino/issues/comments{/number}","contents_url":"https://api.github.com/repos/fantix/gino/contents/{+path}","compare_url":"https://api.github.com/repos/fantix/gino/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fantix/gino/merges","archive_url":"https://api.github.com/repos/fantix/gino/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fantix/gino/downloads","issues_url":"https://api.github.com/repos/fantix/gino/issues{/number}","pulls_url":"https://api.github.com/repos/fantix/gino/pulls{/number}","milestones_url":"https://api.github.com/repos/fantix/gino/milestones{/number}","notifications_url":"https://api.github.com/repos/fantix/gino/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fantix/gino/labels{/name}","releases_url":"https://api.github.com/repos/fantix/gino/releases{/id}","deployments_url":"https://api.github.com/repos/fantix/gino/deployments","created_at":"2017-07-21T04:27:01Z","updated_at":"2018-09-12T16:14:04Z","pushed_at":"2018-09-13T02:12:32Z","git_url":"git://github.com/fantix/gino.git","ssh_url":"git@github.com:fantix/gino.git","clone_url":"https://github.com/fantix/gino.git","svn_url":"https://github.com/fantix/gino","homepage":"","size":946,"stargazers_count":478,"watchers_count":478,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"archived":false,"open_issues_count":22,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":32,"open_issues":22,"watchers":478,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fantix/gino/pulls/334"},"html":{"href":"https://github.com/fantix/gino/pull/334"},"issue":{"href":"https://api.github.com/repos/fantix/gino/issues/334"},"comments":{"href":"https://api.github.com/repos/fantix/gino/issues/334/comments"},"review_comments":{"href":"https://api.github.com/repos/fantix/gino/pulls/334/comments"},"review_comment":{"href":"https://api.github.com/repos/fantix/gino/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fantix/gino/pulls/334/commits"},"statuses":{"href":"https://api.github.com/repos/fantix/gino/statuses/0a8a19983cc57c948b199160b7fe5cae8add13ed"}},"author_association":"OWNER","merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"fantix","id":1751601,"node_id":"MDQ6VXNlcjE3NTE2MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/1751601?v=4","gravatar_id":"","url":"https://api.github.com/users/fantix","html_url":"https://github.com/fantix","followers_url":"https://api.github.com/users/fantix/followers","following_url":"https://api.github.com/users/fantix/following{/other_user}","gists_url":"https://api.github.com/users/fantix/gists{/gist_id}","starred_url":"https://api.github.com/users/fantix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fantix/subscriptions","organizations_url":"https://api.github.com/users/fantix/orgs","repos_url":"https://api.github.com/users/fantix/repos","events_url":"https://api.github.com/users/fantix/events{/privacy}","received_events_url":"https://api.github.com/users/fantix/received_events","type":"User","site_admin":false},"comments":3,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":70,"deletions":22,"changed_files":2}}
{"actor":{"display_login":"fantix"}}