{"action":"created","issue":{"url":"https://api.github.com/repos/ipython/ipykernel/issues/123","repository_url":"https://api.github.com/repos/ipython/ipykernel","labels_url":"https://api.github.com/repos/ipython/ipykernel/issues/123/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipykernel/issues/123/comments","events_url":"https://api.github.com/repos/ipython/ipykernel/issues/123/events","html_url":"https://github.com/ipython/ipykernel/pull/123","id":148263488,"number":123,"title":"Add locking around output buffer","user":{"login":"thomasj02","id":2532431,"avatar_url":"https://avatars.githubusercontent.com/u/2532431?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasj02","html_url":"https://github.com/thomasj02","followers_url":"https://api.github.com/users/thomasj02/followers","following_url":"https://api.github.com/users/thomasj02/following{/other_user}","gists_url":"https://api.github.com/users/thomasj02/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasj02/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasj02/subscriptions","organizations_url":"https://api.github.com/users/thomasj02/orgs","repos_url":"https://api.github.com/users/thomasj02/repos","events_url":"https://api.github.com/users/thomasj02/events{/privacy}","received_events_url":"https://api.github.com/users/thomasj02/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ipython/ipykernel/milestones/12","html_url":"https://github.com/ipython/ipykernel/milestones/4.4","labels_url":"https://api.github.com/repos/ipython/ipykernel/milestones/12/labels","id":1605410,"number":12,"title":"4.4","description":"backports for 4.4","creator":{"login":"minrk","id":151929,"avatar_url":"https://avatars.githubusercontent.com/u/151929?v=3","gravatar_id":"","url":"https://api.github.com/users/minrk","html_url":"https://github.com/minrk","followers_url":"https://api.github.com/users/minrk/followers","following_url":"https://api.github.com/users/minrk/following{/other_user}","gists_url":"https://api.github.com/users/minrk/gists{/gist_id}","starred_url":"https://api.github.com/users/minrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minrk/subscriptions","organizations_url":"https://api.github.com/users/minrk/orgs","repos_url":"https://api.github.com/users/minrk/repos","events_url":"https://api.github.com/users/minrk/events{/privacy}","received_events_url":"https://api.github.com/users/minrk/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":5,"state":"open","created_at":"2016-02-25T14:58:37Z","updated_at":"2016-04-14T12:35:49Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-04-14T06:27:21Z","updated_at":"2016-04-14T12:42:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ipython/ipykernel/pulls/123","html_url":"https://github.com/ipython/ipykernel/pull/123","diff_url":"https://github.com/ipython/ipykernel/pull/123.diff","patch_url":"https://github.com/ipython/ipykernel/pull/123.patch"},"body":"Please bear with me, as this is my first PR. This new locking in this PR appears to fix https://github.com/ipython/ipython/issues/9397, https://github.com/ipython/ipython/issues/9168\r\n\r\nThe lock/unlock does slow down output, but it should only be noticeable for notebooks that are writing data very quickly (i.e., the ones most likely to run into this issue).\r\n\r\nTBH I don't fully understand the threading model in ipykernel, but the fact that the issue was hard to reproduce consistently (plus the fact that the locking seems to fix it) led me to believe it was a multithreading issue. \r\n\r\nApologies in advance if I'm totally off-base on how the threading in ipykernel works."},"comment":{"url":"https://api.github.com/repos/ipython/ipykernel/issues/comments/209918948","html_url":"https://github.com/ipython/ipykernel/pull/123#issuecomment-209918948","issue_url":"https://api.github.com/repos/ipython/ipykernel/issues/123","id":209918948,"user":{"login":"takluyver","id":327925,"avatar_url":"https://avatars.githubusercontent.com/u/327925?v=3","gravatar_id":"","url":"https://api.github.com/users/takluyver","html_url":"https://github.com/takluyver","followers_url":"https://api.github.com/users/takluyver/followers","following_url":"https://api.github.com/users/takluyver/following{/other_user}","gists_url":"https://api.github.com/users/takluyver/gists{/gist_id}","starred_url":"https://api.github.com/users/takluyver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takluyver/subscriptions","organizations_url":"https://api.github.com/users/takluyver/orgs","repos_url":"https://api.github.com/users/takluyver/repos","events_url":"https://api.github.com/users/takluyver/events{/privacy}","received_events_url":"https://api.github.com/users/takluyver/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T12:42:43Z","updated_at":"2016-04-14T12:42:43Z","body":"@minrk in terms of a better approach, would it make sense to pass the data between threads by putting the strings into a `Queue` rather than manipulating `StringIO` instances?"}}