{"action":"created","comment":{"url":"https://api.github.com/repos/python-trio/trio/pulls/comments/209855804","pull_request_review_id":145948172,"id":209855804,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTg1NTgwNA==","diff_hunk":"@@ -0,0 +1,30 @@\n+import threading\n+import time\n+from io import StringIO\n+\n+import contextlib\n+\n+from ..tests.tutil import slow\n+from .. import _run\n+\n+\n+@slow\n+async def test_watchdog():\n+    watchdog = _run.GLOBAL_RUN_CONTEXT.watchdog\n+    target = StringIO()\n+    with contextlib.redirect_stderr(target):\n+        time.sleep(7)\n+\n+    assert target.getvalue().startswith(\n+        \"Trio Watchdog has not received any \"\n+        \"notifications in 5 seconds, main \"\n+        \"thread is blocked!\"\n+    )\n+\n+    # checkpoint to ensure the watchdog gets a notification, sees that its\n+    # dead, and winds down its thread\n+    watchdog.stop()\n+    await _run.checkpoint()\n+    time.sleep(6)  # ensure if the watchdog is waiting for 5s, it wakes\n+    await _run.checkpoint()\n+    assert not watchdog._thread.is_alive()","path":"trio/_core/tests/test_watchdog.py","position":30,"original_position":30,"commit_id":"304273170195cf9f14ad376030b8c25741d9fa9e","original_commit_id":"304273170195cf9f14ad376030b8c25741d9fa9e","user":{"login":"njsmith","id":609896,"node_id":"MDQ6VXNlcjYwOTg5Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/609896?v=4","gravatar_id":"","url":"https://api.github.com/users/njsmith","html_url":"https://github.com/njsmith","followers_url":"https://api.github.com/users/njsmith/followers","following_url":"https://api.github.com/users/njsmith/following{/other_user}","gists_url":"https://api.github.com/users/njsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/njsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njsmith/subscriptions","organizations_url":"https://api.github.com/users/njsmith/orgs","repos_url":"https://api.github.com/users/njsmith/repos","events_url":"https://api.github.com/users/njsmith/events{/privacy}","received_events_url":"https://api.github.com/users/njsmith/received_events","type":"User","site_admin":false},"body":"This looks very delicate... calling `self._event.set()` from `Watchdog.stop()` will help, but even so...\r\n\r\nHere's another idea: make the watchdog thread *not* a daemon, and then join it in `Watchdog.stop`. That way every time we call `trio.run`, we're implicitly checking the watchdog shutdown logic (and also making sure we don't leave stray background threads running, even temporarily). What do you think?","created_at":"2018-08-14T07:44:47Z","updated_at":"2018-08-14T07:44:47Z","html_url":"https://github.com/python-trio/trio/pull/596#discussion_r209855804","pull_request_url":"https://api.github.com/repos/python-trio/trio/pulls/596","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/python-trio/trio/pulls/comments/209855804"},"html":{"href":"https://github.com/python-trio/trio/pull/596#discussion_r209855804"},"pull_request":{"href":"https://api.github.com/repos/python-trio/trio/pulls/596"}}},"pull_request":{"url":"https://api.github.com/repos/python-trio/trio/pulls/596","id":207825938,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3ODI1OTM4","html_url":"https://github.com/python-trio/trio/pull/596","diff_url":"https://github.com/python-trio/trio/pull/596.diff","patch_url":"https://github.com/python-trio/trio/pull/596.patch","issue_url":"https://api.github.com/repos/python-trio/trio/issues/596","number":596,"state":"open","locked":false,"title":"Add task blocked watchdog.","user":{"login":"Fuyukai","id":8783751,"node_id":"MDQ6VXNlcjg3ODM3NTE=","avatar_url":"https://avatars1.githubusercontent.com/u/8783751?v=4","gravatar_id":"","url":"https://api.github.com/users/Fuyukai","html_url":"https://github.com/Fuyukai","followers_url":"https://api.github.com/users/Fuyukai/followers","following_url":"https://api.github.com/users/Fuyukai/following{/other_user}","gists_url":"https://api.github.com/users/Fuyukai/gists{/gist_id}","starred_url":"https://api.github.com/users/Fuyukai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fuyukai/subscriptions","organizations_url":"https://api.github.com/users/Fuyukai/orgs","repos_url":"https://api.github.com/users/Fuyukai/repos","events_url":"https://api.github.com/users/Fuyukai/events{/privacy}","received_events_url":"https://api.github.com/users/Fuyukai/received_events","type":"User","site_admin":false},"body":"Closes #591.","created_at":"2018-08-12T15:16:44Z","updated_at":"2018-08-14T07:44:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0dd89db350f24ec8df9d374bc1a48eccefd232e3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/python-trio/trio/pulls/596/commits","review_comments_url":"https://api.github.com/repos/python-trio/trio/pulls/596/comments","review_comment_url":"https://api.github.com/repos/python-trio/trio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python-trio/trio/issues/596/comments","statuses_url":"https://api.github.com/repos/python-trio/trio/statuses/304273170195cf9f14ad376030b8c25741d9fa9e","head":{"label":"Fuyukai:watchdog","ref":"watchdog","sha":"304273170195cf9f14ad376030b8c25741d9fa9e","user":{"login":"Fuyukai","id":8783751,"node_id":"MDQ6VXNlcjg3ODM3NTE=","avatar_url":"https://avatars1.githubusercontent.com/u/8783751?v=4","gravatar_id":"","url":"https://api.github.com/users/Fuyukai","html_url":"https://github.com/Fuyukai","followers_url":"https://api.github.com/users/Fuyukai/followers","following_url":"https://api.github.com/users/Fuyukai/following{/other_user}","gists_url":"https://api.github.com/users/Fuyukai/gists{/gist_id}","starred_url":"https://api.github.com/users/Fuyukai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fuyukai/subscriptions","organizations_url":"https://api.github.com/users/Fuyukai/orgs","repos_url":"https://api.github.com/users/Fuyukai/repos","events_url":"https://api.github.com/users/Fuyukai/events{/privacy}","received_events_url":"https://api.github.com/users/Fuyukai/received_events","type":"User","site_admin":false},"repo":{"id":114502561,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQ1MDI1NjE=","name":"trio","full_name":"Fuyukai/trio","owner":{"login":"Fuyukai","id":8783751,"node_id":"MDQ6VXNlcjg3ODM3NTE=","avatar_url":"https://avatars1.githubusercontent.com/u/8783751?v=4","gravatar_id":"","url":"https://api.github.com/users/Fuyukai","html_url":"https://github.com/Fuyukai","followers_url":"https://api.github.com/users/Fuyukai/followers","following_url":"https://api.github.com/users/Fuyukai/following{/other_user}","gists_url":"https://api.github.com/users/Fuyukai/gists{/gist_id}","starred_url":"https://api.github.com/users/Fuyukai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fuyukai/subscriptions","organizations_url":"https://api.github.com/users/Fuyukai/orgs","repos_url":"https://api.github.com/users/Fuyukai/repos","events_url":"https://api.github.com/users/Fuyukai/events{/privacy}","received_events_url":"https://api.github.com/users/Fuyukai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Fuyukai/trio","description":"Trio – Pythonic async I/O for humans and snake people 🐍","fork":true,"url":"https://api.github.com/repos/Fuyukai/trio","forks_url":"https://api.github.com/repos/Fuyukai/trio/forks","keys_url":"https://api.github.com/repos/Fuyukai/trio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Fuyukai/trio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Fuyukai/trio/teams","hooks_url":"https://api.github.com/repos/Fuyukai/trio/hooks","issue_events_url":"https://api.github.com/repos/Fuyukai/trio/issues/events{/number}","events_url":"https://api.github.com/repos/Fuyukai/trio/events","assignees_url":"https://api.github.com/repos/Fuyukai/trio/assignees{/user}","branches_url":"https://api.github.com/repos/Fuyukai/trio/branches{/branch}","tags_url":"https://api.github.com/repos/Fuyukai/trio/tags","blobs_url":"https://api.github.com/repos/Fuyukai/trio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Fuyukai/trio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Fuyukai/trio/git/refs{/sha}","trees_url":"https://api.github.com/repos/Fuyukai/trio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Fuyukai/trio/statuses/{sha}","languages_url":"https://api.github.com/repos/Fuyukai/trio/languages","stargazers_url":"https://api.github.com/repos/Fuyukai/trio/stargazers","contributors_url":"https://api.github.com/repos/Fuyukai/trio/contributors","subscribers_url":"https://api.github.com/repos/Fuyukai/trio/subscribers","subscription_url":"https://api.github.com/repos/Fuyukai/trio/subscription","commits_url":"https://api.github.com/repos/Fuyukai/trio/commits{/sha}","git_commits_url":"https://api.github.com/repos/Fuyukai/trio/git/commits{/sha}","comments_url":"https://api.github.com/repos/Fuyukai/trio/comments{/number}","issue_comment_url":"https://api.github.com/repos/Fuyukai/trio/issues/comments{/number}","contents_url":"https://api.github.com/repos/Fuyukai/trio/contents/{+path}","compare_url":"https://api.github.com/repos/Fuyukai/trio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Fuyukai/trio/merges","archive_url":"https://api.github.com/repos/Fuyukai/trio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Fuyukai/trio/downloads","issues_url":"https://api.github.com/repos/Fuyukai/trio/issues{/number}","pulls_url":"https://api.github.com/repos/Fuyukai/trio/pulls{/number}","milestones_url":"https://api.github.com/repos/Fuyukai/trio/milestones{/number}","notifications_url":"https://api.github.com/repos/Fuyukai/trio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Fuyukai/trio/labels{/name}","releases_url":"https://api.github.com/repos/Fuyukai/trio/releases{/id}","deployments_url":"https://api.github.com/repos/Fuyukai/trio/deployments","created_at":"2017-12-17T01:54:20Z","updated_at":"2018-08-13T13:11:32Z","pushed_at":"2018-08-13T13:21:21Z","git_url":"git://github.com/Fuyukai/trio.git","ssh_url":"git@github.com:Fuyukai/trio.git","clone_url":"https://github.com/Fuyukai/trio.git","svn_url":"https://github.com/Fuyukai/trio","homepage":"","size":2212,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"python-trio:master","ref":"master","sha":"c6309c119fc93c3ac785030e1f2934f31d430631","user":{"login":"python-trio","id":26335827,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2MzM1ODI3","avatar_url":"https://avatars2.githubusercontent.com/u/26335827?v=4","gravatar_id":"","url":"https://api.github.com/users/python-trio","html_url":"https://github.com/python-trio","followers_url":"https://api.github.com/users/python-trio/followers","following_url":"https://api.github.com/users/python-trio/following{/other_user}","gists_url":"https://api.github.com/users/python-trio/gists{/gist_id}","starred_url":"https://api.github.com/users/python-trio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-trio/subscriptions","organizations_url":"https://api.github.com/users/python-trio/orgs","repos_url":"https://api.github.com/users/python-trio/repos","events_url":"https://api.github.com/users/python-trio/events{/privacy}","received_events_url":"https://api.github.com/users/python-trio/received_events","type":"Organization","site_admin":false},"repo":{"id":79083614,"node_id":"MDEwOlJlcG9zaXRvcnk3OTA4MzYxNA==","name":"trio","full_name":"python-trio/trio","owner":{"login":"python-trio","id":26335827,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2MzM1ODI3","avatar_url":"https://avatars2.githubusercontent.com/u/26335827?v=4","gravatar_id":"","url":"https://api.github.com/users/python-trio","html_url":"https://github.com/python-trio","followers_url":"https://api.github.com/users/python-trio/followers","following_url":"https://api.github.com/users/python-trio/following{/other_user}","gists_url":"https://api.github.com/users/python-trio/gists{/gist_id}","starred_url":"https://api.github.com/users/python-trio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-trio/subscriptions","organizations_url":"https://api.github.com/users/python-trio/orgs","repos_url":"https://api.github.com/users/python-trio/repos","events_url":"https://api.github.com/users/python-trio/events{/privacy}","received_events_url":"https://api.github.com/users/python-trio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-trio/trio","description":"Trio – Pythonic async I/O for humans and snake people 🐍","fork":false,"url":"https://api.github.com/repos/python-trio/trio","forks_url":"https://api.github.com/repos/python-trio/trio/forks","keys_url":"https://api.github.com/repos/python-trio/trio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-trio/trio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-trio/trio/teams","hooks_url":"https://api.github.com/repos/python-trio/trio/hooks","issue_events_url":"https://api.github.com/repos/python-trio/trio/issues/events{/number}","events_url":"https://api.github.com/repos/python-trio/trio/events","assignees_url":"https://api.github.com/repos/python-trio/trio/assignees{/user}","branches_url":"https://api.github.com/repos/python-trio/trio/branches{/branch}","tags_url":"https://api.github.com/repos/python-trio/trio/tags","blobs_url":"https://api.github.com/repos/python-trio/trio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-trio/trio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-trio/trio/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-trio/trio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-trio/trio/statuses/{sha}","languages_url":"https://api.github.com/repos/python-trio/trio/languages","stargazers_url":"https://api.github.com/repos/python-trio/trio/stargazers","contributors_url":"https://api.github.com/repos/python-trio/trio/contributors","subscribers_url":"https://api.github.com/repos/python-trio/trio/subscribers","subscription_url":"https://api.github.com/repos/python-trio/trio/subscription","commits_url":"https://api.github.com/repos/python-trio/trio/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-trio/trio/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-trio/trio/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-trio/trio/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-trio/trio/contents/{+path}","compare_url":"https://api.github.com/repos/python-trio/trio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-trio/trio/merges","archive_url":"https://api.github.com/repos/python-trio/trio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-trio/trio/downloads","issues_url":"https://api.github.com/repos/python-trio/trio/issues{/number}","pulls_url":"https://api.github.com/repos/python-trio/trio/pulls{/number}","milestones_url":"https://api.github.com/repos/python-trio/trio/milestones{/number}","notifications_url":"https://api.github.com/repos/python-trio/trio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-trio/trio/labels{/name}","releases_url":"https://api.github.com/repos/python-trio/trio/releases{/id}","deployments_url":"https://api.github.com/repos/python-trio/trio/deployments","created_at":"2017-01-16T04:45:25Z","updated_at":"2018-08-14T01:28:46Z","pushed_at":"2018-08-13T13:37:51Z","git_url":"git://github.com/python-trio/trio.git","ssh_url":"git@github.com:python-trio/trio.git","clone_url":"https://github.com/python-trio/trio.git","svn_url":"https://github.com/python-trio/trio","homepage":"https://trio.readthedocs.io","size":2196,"stargazers_count":1361,"watchers_count":1361,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":86,"mirror_url":null,"archived":false,"open_issues_count":163,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":86,"open_issues":163,"watchers":1361,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python-trio/trio/pulls/596"},"html":{"href":"https://github.com/python-trio/trio/pull/596"},"issue":{"href":"https://api.github.com/repos/python-trio/trio/issues/596"},"comments":{"href":"https://api.github.com/repos/python-trio/trio/issues/596/comments"},"review_comments":{"href":"https://api.github.com/repos/python-trio/trio/pulls/596/comments"},"review_comment":{"href":"https://api.github.com/repos/python-trio/trio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python-trio/trio/pulls/596/commits"},"statuses":{"href":"https://api.github.com/repos/python-trio/trio/statuses/304273170195cf9f14ad376030b8c25741d9fa9e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"njsmith"}}