{"action":"created","issue":{"url":"https://api.github.com/repos/python-trio/trio/issues/147","repository_url":"https://api.github.com/repos/python-trio/trio","labels_url":"https://api.github.com/repos/python-trio/trio/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/python-trio/trio/issues/147/comments","events_url":"https://api.github.com/repos/python-trio/trio/issues/147/events","html_url":"https://github.com/python-trio/trio/issues/147","id":225853334,"number":147,"title":"Add shield argument to move_on_after and other convenience functions","user":{"login":"merrellb","id":309627,"avatar_url":"https://avatars1.githubusercontent.com/u/309627?v=3","gravatar_id":"","url":"https://api.github.com/users/merrellb","html_url":"https://github.com/merrellb","followers_url":"https://api.github.com/users/merrellb/followers","following_url":"https://api.github.com/users/merrellb/following{/other_user}","gists_url":"https://api.github.com/users/merrellb/gists{/gist_id}","starred_url":"https://api.github.com/users/merrellb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merrellb/subscriptions","organizations_url":"https://api.github.com/users/merrellb/orgs","repos_url":"https://api.github.com/users/merrellb/repos","events_url":"https://api.github.com/users/merrellb/events{/privacy}","received_events_url":"https://api.github.com/users/merrellb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-05-02T23:52:36Z","updated_at":"2017-05-08T06:05:04Z","closed_at":null,"body":"The documentation suggests assigning a cancel scope and setting shield as two separate steps:\r\n```\r\nwith move_on_after(CLEANUP_TIMEOUT) as cleanup_scope:\r\n    cleanup_scope.shield = True\r\n    await conn.send_goodbye_msg()\r\n```\r\nHowever ```trio.open_cancel_scope``` has a ```shield``` argument and it seems like it would also make sense with the convenience functions (```trio.move_on_after, trio.move_on_at, trio.fail_after and trio.fail_at```). eg:\r\n```\r\nwith move_on_after(CLEANUP_TIMEOUT, shield=True):\r\n    await conn.send_goodbye_msg()\r\n```\r\nI would be happy to make the pull-request if this change makes sense."},"comment":{"url":"https://api.github.com/repos/python-trio/trio/issues/comments/299780546","html_url":"https://github.com/python-trio/trio/issues/147#issuecomment-299780546","issue_url":"https://api.github.com/repos/python-trio/trio/issues/147","id":299780546,"user":{"login":"merrellb","id":309627,"avatar_url":"https://avatars1.githubusercontent.com/u/309627?v=3","gravatar_id":"","url":"https://api.github.com/users/merrellb","html_url":"https://github.com/merrellb","followers_url":"https://api.github.com/users/merrellb/followers","following_url":"https://api.github.com/users/merrellb/following{/other_user}","gists_url":"https://api.github.com/users/merrellb/gists{/gist_id}","starred_url":"https://api.github.com/users/merrellb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merrellb/subscriptions","organizations_url":"https://api.github.com/users/merrellb/orgs","repos_url":"https://api.github.com/users/merrellb/repos","events_url":"https://api.github.com/users/merrellb/events{/privacy}","received_events_url":"https://api.github.com/users/merrellb/received_events","type":"User","site_admin":false},"created_at":"2017-05-08T06:05:04Z","updated_at":"2017-05-08T06:05:04Z","body":"At the application level, I think this might be fairly common.  For example, I may want to make a call to a local database (ie something with time constraints we understand fairly well), storing the last record acknowledged by a remote WebSocket client.  With nursery cancellation as the best way to manage a group of tasks, I think this may come up in many circumstances other than control-C.\r\n\r\nI am not sure I understand your concerns about adding ```shield``` to ```move_on_after```. Isn't that exactly what we should be wrapping our graceful connection shutdown code within?  With a server spawning a nursery per incoming connection, how could handle this at a higher level?"}}
{"actor":{"display_login":"merrellb"}}