{"action":"created","issue":{"url":"https://api.github.com/repos/snower/TorMySQL/issues/36","repository_url":"https://api.github.com/repos/snower/TorMySQL","labels_url":"https://api.github.com/repos/snower/TorMySQL/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/snower/TorMySQL/issues/36/comments","events_url":"https://api.github.com/repos/snower/TorMySQL/issues/36/events","html_url":"https://github.com/snower/TorMySQL/pull/36","id":336238100,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3NzM5Mzcz","number":36,"title":"with conn 退出时处理事务","user":{"login":"007gzs","id":5856259,"node_id":"MDQ6VXNlcjU4NTYyNTk=","avatar_url":"https://avatars2.githubusercontent.com/u/5856259?v=4","gravatar_id":"","url":"https://api.github.com/users/007gzs","html_url":"https://github.com/007gzs","followers_url":"https://api.github.com/users/007gzs/followers","following_url":"https://api.github.com/users/007gzs/following{/other_user}","gists_url":"https://api.github.com/users/007gzs/gists{/gist_id}","starred_url":"https://api.github.com/users/007gzs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/007gzs/subscriptions","organizations_url":"https://api.github.com/users/007gzs/orgs","repos_url":"https://api.github.com/users/007gzs/repos","events_url":"https://api.github.com/users/007gzs/events{/privacy}","received_events_url":"https://api.github.com/users/007gzs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-27T13:47:57Z","updated_at":"2018-06-28T03:13:14Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/snower/TorMySQL/pulls/36","html_url":"https://github.com/snower/TorMySQL/pull/36","diff_url":"https://github.com/snower/TorMySQL/pull/36.diff","patch_url":"https://github.com/snower/TorMySQL/pull/36.patch"},"body":"pymysql 中 \r\n\r\n```\r\nwith pymysql.connect(xxx) as conn:\r\n    xxxx\r\n```\r\n执行后会自动处理事务 `On successful exit, commit. On exception, rollback`\r\n但是tormysql中没有对事务做操作，作者是有什么其他考虑么@snower\r\n\r\nhttps://github.com/PyMySQL/PyMySQL/blob/2fca94f24302591ba54e473d7a5cacba4111ae84/pymysql/connections.py#L500-L504"},"comment":{"url":"https://api.github.com/repos/snower/TorMySQL/issues/comments/400897274","html_url":"https://github.com/snower/TorMySQL/pull/36#issuecomment-400897274","issue_url":"https://api.github.com/repos/snower/TorMySQL/issues/36","id":400897274,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDg5NzI3NA==","user":{"login":"snower","id":2220463,"node_id":"MDQ6VXNlcjIyMjA0NjM=","avatar_url":"https://avatars3.githubusercontent.com/u/2220463?v=4","gravatar_id":"","url":"https://api.github.com/users/snower","html_url":"https://github.com/snower","followers_url":"https://api.github.com/users/snower/followers","following_url":"https://api.github.com/users/snower/following{/other_user}","gists_url":"https://api.github.com/users/snower/gists{/gist_id}","starred_url":"https://api.github.com/users/snower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snower/subscriptions","organizations_url":"https://api.github.com/users/snower/orgs","repos_url":"https://api.github.com/users/snower/repos","events_url":"https://api.github.com/users/snower/events{/privacy}","received_events_url":"https://api.github.com/users/snower/received_events","type":"User","site_admin":false},"created_at":"2018-06-28T03:13:14Z","updated_at":"2018-06-28T03:13:14Z","author_association":"OWNER","body":"首先这么设计当然是有原因的\r\n\r\ntormysql是异步io的mysql driver，所以所有可能设计到io操作的函数都必须用coroutine包裹，并等待协程完成。\r\n\r\npython2中with语法是无法使用coroutine并yield等待协程执行完成的，所以才在python2下是无法用with语法中自动rollback或commit的。\r\n\r\n在python3下，有async with的支持，所以可用在with语法中自动rollback或commit，而这个确实也在啊async的with语法中实现了，只不过是用exec执行字符串的方式定义了这两个函数，之所以要这么做也是在python2下有async语法会直接语法错误无法使用，而用exec执行字符串定义行数本身也没有什么问题。\r\n\r\npymysql是同步io的库，两者不能同类比啊。\r\n整个库已经在生产环境中高并发场景下证明在链接管理，事务提交上确实是没有问题的，稳定性和性能确实已经是所以异步io场景下最高的了。"}}
{"actor":{"display_login":"snower"}}