{"action":"created","issue":{"url":"https://api.github.com/repos/alex/alchimia/issues/31","repository_url":"https://api.github.com/repos/alex/alchimia","labels_url":"https://api.github.com/repos/alex/alchimia/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/alex/alchimia/issues/31/comments","events_url":"https://api.github.com/repos/alex/alchimia/issues/31/events","html_url":"https://github.com/alex/alchimia/pull/31","id":181599958,"number":31,"title":"Async context manager for transactions","user":{"login":"hawkowl","id":3307100,"avatar_url":"https://avatars.githubusercontent.com/u/3307100?v=3","gravatar_id":"","url":"https://api.github.com/users/hawkowl","html_url":"https://github.com/hawkowl","followers_url":"https://api.github.com/users/hawkowl/followers","following_url":"https://api.github.com/users/hawkowl/following{/other_user}","gists_url":"https://api.github.com/users/hawkowl/gists{/gist_id}","starred_url":"https://api.github.com/users/hawkowl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hawkowl/subscriptions","organizations_url":"https://api.github.com/users/hawkowl/orgs","repos_url":"https://api.github.com/users/hawkowl/repos","events_url":"https://api.github.com/users/hawkowl/events{/privacy}","received_events_url":"https://api.github.com/users/hawkowl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-07T07:15:12Z","updated_at":"2016-10-08T05:04:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/alex/alchimia/pulls/31","html_url":"https://github.com/alex/alchimia/pull/31","diff_url":"https://github.com/alex/alchimia/pull/31.diff","patch_url":"https://github.com/alex/alchimia/pull/31.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/alex/alchimia/issues/comments/252403300","html_url":"https://github.com/alex/alchimia/pull/31#issuecomment-252403300","issue_url":"https://api.github.com/repos/alex/alchimia/issues/31","id":252403300,"user":{"login":"glyph","id":716529,"avatar_url":"https://avatars.githubusercontent.com/u/716529?v=3","gravatar_id":"","url":"https://api.github.com/users/glyph","html_url":"https://github.com/glyph","followers_url":"https://api.github.com/users/glyph/followers","following_url":"https://api.github.com/users/glyph/following{/other_user}","gists_url":"https://api.github.com/users/glyph/gists{/gist_id}","starred_url":"https://api.github.com/users/glyph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glyph/subscriptions","organizations_url":"https://api.github.com/users/glyph/orgs","repos_url":"https://api.github.com/users/glyph/repos","events_url":"https://api.github.com/users/glyph/events{/privacy}","received_events_url":"https://api.github.com/users/glyph/received_events","type":"User","site_admin":false},"created_at":"2016-10-08T05:04:02Z","updated_at":"2016-10-08T05:04:02Z","body":"I love the idea for the feature, and the docs are great.\r\n\r\nHowever, I don't love using an async context manager for this.  For some simple cases, it might be good to have a context manager, but there are a number of reasons to avoid it:\r\n\r\n1. There's the obvious point that it only works in 3.5+.  Still a lot of legacy code that won't be usable with this for years to come; transactions are not a \"fancy\" or optional feature. You need them for any even halfway-functioning SQL application.\r\n2. It's an abstraction inversion.  There should be a nice transaction object which can be started and finished with just regular ol' methods before we get into a specific convenience layer (in large part because if this `async with` convenience layer is a good idea).\r\n3. It's a limiting design, because it highlights one of the weaknesses of context managers generally: the only-execute-once nature of their specification.  In more sophisticated / concurrent database applications, transactions which create conflicts should be automatically retried.  This means the transaction needs to be a callable, that can be called multiple times.  Context managers have no API for re-entering, and it would be awkward in the extreme to require everyone who wants correct, retry-on-conflict transactions to do something like `async with Transaction(...) as blub: while blub.transaction_should_keep_going: try: ... except RetriableTransactionException: pass`"}}
{"actor":{"display_login":"glyph"}}