{"action":"created","issue":{"url":"https://api.github.com/repos/jeamland/wsproto/issues/11","repository_url":"https://api.github.com/repos/jeamland/wsproto","labels_url":"https://api.github.com/repos/jeamland/wsproto/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/jeamland/wsproto/issues/11/comments","events_url":"https://api.github.com/repos/jeamland/wsproto/issues/11/events","html_url":"https://github.com/jeamland/wsproto/pull/11","id":192254236,"number":11,"title":"[wip] rewrite frame_protocol.py using yield from","user":{"login":"njsmith","id":609896,"avatar_url":"https://avatars.githubusercontent.com/u/609896?v=3","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},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-29T11:16:41Z","updated_at":"2016-11-30T07:30:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jeamland/wsproto/pulls/11","html_url":"https://github.com/jeamland/wsproto/pull/11","diff_url":"https://github.com/jeamland/wsproto/pull/11.diff","patch_url":"https://github.com/jeamland/wsproto/pull/11.patch"},"body":"This isn't complete -- it definitely doesn't pass the autobahn test suite\r\nyet. But I'm posting it to give an idea of what I'm thinking about.\r\n\r\nThe main thing is to rewrite the frame_protocol.py state machine as linear\r\ncode, using 'yield from'. This creates a hard requirement for Python 3.3+.\r\nBut given that no-one uses 3.3, and 3.3 is missing enum, and 3.3's\r\nbytearray has quadratic behavior in the way I'm using it, in practice I\r\nthink the minimum supported version should be 3.4.\r\n\r\nI think the code is much, much clearer. Behaviorally, the main change is\r\nthat we know emit partial data frames as we receive them. This is (almost)\r\ninvisible to the client (it just looks like peer is sending smaller\r\nfragments -- except that we do expose where the actual fragment boundaries\r\nwere in case there are any experts who really want to know this), while\r\navoiding potential DoS issues and allowing users to get better streaming\r\nbehavior.\r\n\r\nI believe (but haven't checked) that it should be faster too -- in\r\nparticular from removing the str/bytes += loop in add_message_payload.\r\n\r\nIt also gives better error messages on protocol errors.\r\n\r\nIt also fixes some technically unrelated bugs I noticed along the way:\r\n\r\n- Lots of fragmentation-related bugs in PerMessageDeflate code\r\n- Replace some O(n**2) data structure usage with O(n) equivalents\r\n- Report correct CLOSE codes in more places\r\n- Fix spelling of TLS_HANDSHAKE_FAILED\r\n- Don't echo local-only CLOSE reasons back to the server\r\n- Maybe some others I'm forgetting...\r\n"},"comment":{"url":"https://api.github.com/repos/jeamland/wsproto/issues/comments/263803008","html_url":"https://github.com/jeamland/wsproto/pull/11#issuecomment-263803008","issue_url":"https://api.github.com/repos/jeamland/wsproto/issues/11","id":263803008,"user":{"login":"codecov-io","id":8655789,"avatar_url":"https://avatars.githubusercontent.com/u/8655789?v=3","gravatar_id":"","url":"https://api.github.com/users/codecov-io","html_url":"https://github.com/codecov-io","followers_url":"https://api.github.com/users/codecov-io/followers","following_url":"https://api.github.com/users/codecov-io/following{/other_user}","gists_url":"https://api.github.com/users/codecov-io/gists{/gist_id}","starred_url":"https://api.github.com/users/codecov-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codecov-io/subscriptions","organizations_url":"https://api.github.com/users/codecov-io/orgs","repos_url":"https://api.github.com/users/codecov-io/repos","events_url":"https://api.github.com/users/codecov-io/events{/privacy}","received_events_url":"https://api.github.com/users/codecov-io/received_events","type":"User","site_admin":false},"created_at":"2016-11-30T07:30:35Z","updated_at":"2016-11-30T07:30:35Z","body":"## [Current coverage](https://codecov.io/gh/jeamland/wsproto/pull/11?src=pr) is 30.20% (diff: 15.27%)\n> Merging [#11](https://codecov.io/gh/jeamland/wsproto/pull/11?src=pr) into [master](https://codecov.io/gh/jeamland/wsproto/branch/master?src=pr) will increase coverage by **1.36%**\n\n```diff\n@@             master        #11   diff @@\n==========================================\n  Files             5          5          \n  Lines           697        649    -48   \n  Methods           0          0          \n  Messages          0          0          \n  Branches        170        147    -23   \n==========================================\n- Hits            201        196     -5   \n+ Misses          476        433    -43   \n  Partials         20         20          \n```\n\n> Powered by [Codecov](https://codecov.io?src=pr). Last update [84476b2...40299b4](https://codecov.io/gh/jeamland/wsproto/compare/84476b204ddb46b764ff12f3bac887cd229ed6d4...40299b4c06ef7dab6c6e8cc2a12871efeb21e88d?src=pr)"}}
{"actor":{"display_login":"codecov-io"}}