{"action":"closed","number":44,"pull_request":{"url":"https://api.github.com/repos/laterpay/anton/pulls/44","id":33535583,"html_url":"https://github.com/laterpay/anton/pull/44","diff_url":"https://github.com/laterpay/anton/pull/44.diff","patch_url":"https://github.com/laterpay/anton/pull/44.patch","issue_url":"https://api.github.com/repos/laterpay/anton/issues/44","number":44,"state":"closed","locked":false,"title":"Refactor IRC client into multiple Greenlets","user":{"login":"jdelic","id":1956349,"avatar_url":"https://avatars.githubusercontent.com/u/1956349?v=3","gravatar_id":"","url":"https://api.github.com/users/jdelic","html_url":"https://github.com/jdelic","followers_url":"https://api.github.com/users/jdelic/followers","following_url":"https://api.github.com/users/jdelic/following{/other_user}","gists_url":"https://api.github.com/users/jdelic/gists{/gist_id}","starred_url":"https://api.github.com/users/jdelic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdelic/subscriptions","organizations_url":"https://api.github.com/users/jdelic/orgs","repos_url":"https://api.github.com/users/jdelic/repos","events_url":"https://api.github.com/users/jdelic/events{/privacy}","received_events_url":"https://api.github.com/users/jdelic/received_events","type":"User","site_admin":false},"body":"The way we did it before ... worked, unless the HTTP module which is entirely cooperatively multithreaded tried to send messages too fast. That could result in https://sentry.sys.laterpay.net/laterpay/sys/group/2600/ (`AssertionError: gevent.socket in _wait - This socket is already used by another greenlet`).\r\n\r\nThis PR refactors the IRC module in three cooperative threads:\r\n  1. a watcher greenlet that handles socket disconnects from the IRC server\r\n  2. a reader greenlet that reads incoming messages and dispatches them to anton modules\r\n  3. a writer greenlet that writes messages from a fifo queue to the IRC server\r\n\r\n`chanmsg` and `privmsg` now only queue messages to be sent to the IRC server.\r\n\r\nIn the future this will also allow us to throttle message throughput so as not to trip flood protections. \r\n\r\nAlso, instead of running `while True` this PR makes the watcher thread check `Event` instances, which will also make it easy to handle system signals correctly in the future. And finally, the new architecture allows `anton.irc_client.Client` to run standalone (through `run_eventloop`) if you ever wanted to run it without on relying the `WSGIServer.serve_forever` event loop we've been relying on previously.","created_at":"2015-04-17T11:24:49Z","updated_at":"2015-04-24T14:50:25Z","closed_at":"2015-04-24T14:50:25Z","merged_at":"2015-04-24T14:50:25Z","merge_commit_sha":"52ab5e4f1058838d23aade3e1247c4ec7c30a6a0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/laterpay/anton/pulls/44/commits","review_comments_url":"https://api.github.com/repos/laterpay/anton/pulls/44/comments","review_comment_url":"https://api.github.com/repos/laterpay/anton/pulls/comments{/number}","comments_url":"https://api.github.com/repos/laterpay/anton/issues/44/comments","statuses_url":"https://api.github.com/repos/laterpay/anton/statuses/aa7a3d7f173ce128b4be0507aa1bbb8473541ed0","head":{"label":"laterpay:feature/refactor-IRC-client-into-multiple-greenlets","ref":"feature/refactor-IRC-client-into-multiple-greenlets","sha":"aa7a3d7f173ce128b4be0507aa1bbb8473541ed0","user":{"login":"laterpay","id":1955984,"avatar_url":"https://avatars.githubusercontent.com/u/1955984?v=3","gravatar_id":"","url":"https://api.github.com/users/laterpay","html_url":"https://github.com/laterpay","followers_url":"https://api.github.com/users/laterpay/followers","following_url":"https://api.github.com/users/laterpay/following{/other_user}","gists_url":"https://api.github.com/users/laterpay/gists{/gist_id}","starred_url":"https://api.github.com/users/laterpay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laterpay/subscriptions","organizations_url":"https://api.github.com/users/laterpay/orgs","repos_url":"https://api.github.com/users/laterpay/repos","events_url":"https://api.github.com/users/laterpay/events{/privacy}","received_events_url":"https://api.github.com/users/laterpay/received_events","type":"Organization","site_admin":false},"repo":{"id":6864592,"name":"anton","full_name":"laterpay/anton","owner":{"login":"laterpay","id":1955984,"avatar_url":"https://avatars.githubusercontent.com/u/1955984?v=3","gravatar_id":"","url":"https://api.github.com/users/laterpay","html_url":"https://github.com/laterpay","followers_url":"https://api.github.com/users/laterpay/followers","following_url":"https://api.github.com/users/laterpay/following{/other_user}","gists_url":"https://api.github.com/users/laterpay/gists{/gist_id}","starred_url":"https://api.github.com/users/laterpay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laterpay/subscriptions","organizations_url":"https://api.github.com/users/laterpay/orgs","repos_url":"https://api.github.com/users/laterpay/repos","events_url":"https://api.github.com/users/laterpay/events{/privacy}","received_events_url":"https://api.github.com/users/laterpay/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/laterpay/anton","description":"LaterPay's IRC Bot. Fork of https://bitbucket.org/chrisporter/holly/","fork":false,"url":"https://api.github.com/repos/laterpay/anton","forks_url":"https://api.github.com/repos/laterpay/anton/forks","keys_url":"https://api.github.com/repos/laterpay/anton/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laterpay/anton/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laterpay/anton/teams","hooks_url":"https://api.github.com/repos/laterpay/anton/hooks","issue_events_url":"https://api.github.com/repos/laterpay/anton/issues/events{/number}","events_url":"https://api.github.com/repos/laterpay/anton/events","assignees_url":"https://api.github.com/repos/laterpay/anton/assignees{/user}","branches_url":"https://api.github.com/repos/laterpay/anton/branches{/branch}","tags_url":"https://api.github.com/repos/laterpay/anton/tags","blobs_url":"https://api.github.com/repos/laterpay/anton/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laterpay/anton/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laterpay/anton/git/refs{/sha}","trees_url":"https://api.github.com/repos/laterpay/anton/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laterpay/anton/statuses/{sha}","languages_url":"https://api.github.com/repos/laterpay/anton/languages","stargazers_url":"https://api.github.com/repos/laterpay/anton/stargazers","contributors_url":"https://api.github.com/repos/laterpay/anton/contributors","subscribers_url":"https://api.github.com/repos/laterpay/anton/subscribers","subscription_url":"https://api.github.com/repos/laterpay/anton/subscription","commits_url":"https://api.github.com/repos/laterpay/anton/commits{/sha}","git_commits_url":"https://api.github.com/repos/laterpay/anton/git/commits{/sha}","comments_url":"https://api.github.com/repos/laterpay/anton/comments{/number}","issue_comment_url":"https://api.github.com/repos/laterpay/anton/issues/comments{/number}","contents_url":"https://api.github.com/repos/laterpay/anton/contents/{+path}","compare_url":"https://api.github.com/repos/laterpay/anton/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laterpay/anton/merges","archive_url":"https://api.github.com/repos/laterpay/anton/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laterpay/anton/downloads","issues_url":"https://api.github.com/repos/laterpay/anton/issues{/number}","pulls_url":"https://api.github.com/repos/laterpay/anton/pulls{/number}","milestones_url":"https://api.github.com/repos/laterpay/anton/milestones{/number}","notifications_url":"https://api.github.com/repos/laterpay/anton/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laterpay/anton/labels{/name}","releases_url":"https://api.github.com/repos/laterpay/anton/releases{/id}","created_at":"2012-11-26T12:08:21Z","updated_at":"2015-04-09T16:00:15Z","pushed_at":"2015-04-24T14:50:25Z","git_url":"git://github.com/laterpay/anton.git","ssh_url":"git@github.com:laterpay/anton.git","clone_url":"https://github.com/laterpay/anton.git","svn_url":"https://github.com/laterpay/anton","homepage":"http://www.youtube.com/watch?v=D6hwDOnZzpc","size":1512,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":10,"forks":2,"open_issues":10,"watchers":1,"default_branch":"master"}},"base":{"label":"laterpay:master","ref":"master","sha":"a348e8b2bf0ea3265422c3138cda9c0e457584ee","user":{"login":"laterpay","id":1955984,"avatar_url":"https://avatars.githubusercontent.com/u/1955984?v=3","gravatar_id":"","url":"https://api.github.com/users/laterpay","html_url":"https://github.com/laterpay","followers_url":"https://api.github.com/users/laterpay/followers","following_url":"https://api.github.com/users/laterpay/following{/other_user}","gists_url":"https://api.github.com/users/laterpay/gists{/gist_id}","starred_url":"https://api.github.com/users/laterpay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laterpay/subscriptions","organizations_url":"https://api.github.com/users/laterpay/orgs","repos_url":"https://api.github.com/users/laterpay/repos","events_url":"https://api.github.com/users/laterpay/events{/privacy}","received_events_url":"https://api.github.com/users/laterpay/received_events","type":"Organization","site_admin":false},"repo":{"id":6864592,"name":"anton","full_name":"laterpay/anton","owner":{"login":"laterpay","id":1955984,"avatar_url":"https://avatars.githubusercontent.com/u/1955984?v=3","gravatar_id":"","url":"https://api.github.com/users/laterpay","html_url":"https://github.com/laterpay","followers_url":"https://api.github.com/users/laterpay/followers","following_url":"https://api.github.com/users/laterpay/following{/other_user}","gists_url":"https://api.github.com/users/laterpay/gists{/gist_id}","starred_url":"https://api.github.com/users/laterpay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laterpay/subscriptions","organizations_url":"https://api.github.com/users/laterpay/orgs","repos_url":"https://api.github.com/users/laterpay/repos","events_url":"https://api.github.com/users/laterpay/events{/privacy}","received_events_url":"https://api.github.com/users/laterpay/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/laterpay/anton","description":"LaterPay's IRC Bot. Fork of https://bitbucket.org/chrisporter/holly/","fork":false,"url":"https://api.github.com/repos/laterpay/anton","forks_url":"https://api.github.com/repos/laterpay/anton/forks","keys_url":"https://api.github.com/repos/laterpay/anton/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laterpay/anton/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laterpay/anton/teams","hooks_url":"https://api.github.com/repos/laterpay/anton/hooks","issue_events_url":"https://api.github.com/repos/laterpay/anton/issues/events{/number}","events_url":"https://api.github.com/repos/laterpay/anton/events","assignees_url":"https://api.github.com/repos/laterpay/anton/assignees{/user}","branches_url":"https://api.github.com/repos/laterpay/anton/branches{/branch}","tags_url":"https://api.github.com/repos/laterpay/anton/tags","blobs_url":"https://api.github.com/repos/laterpay/anton/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laterpay/anton/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laterpay/anton/git/refs{/sha}","trees_url":"https://api.github.com/repos/laterpay/anton/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laterpay/anton/statuses/{sha}","languages_url":"https://api.github.com/repos/laterpay/anton/languages","stargazers_url":"https://api.github.com/repos/laterpay/anton/stargazers","contributors_url":"https://api.github.com/repos/laterpay/anton/contributors","subscribers_url":"https://api.github.com/repos/laterpay/anton/subscribers","subscription_url":"https://api.github.com/repos/laterpay/anton/subscription","commits_url":"https://api.github.com/repos/laterpay/anton/commits{/sha}","git_commits_url":"https://api.github.com/repos/laterpay/anton/git/commits{/sha}","comments_url":"https://api.github.com/repos/laterpay/anton/comments{/number}","issue_comment_url":"https://api.github.com/repos/laterpay/anton/issues/comments{/number}","contents_url":"https://api.github.com/repos/laterpay/anton/contents/{+path}","compare_url":"https://api.github.com/repos/laterpay/anton/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laterpay/anton/merges","archive_url":"https://api.github.com/repos/laterpay/anton/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laterpay/anton/downloads","issues_url":"https://api.github.com/repos/laterpay/anton/issues{/number}","pulls_url":"https://api.github.com/repos/laterpay/anton/pulls{/number}","milestones_url":"https://api.github.com/repos/laterpay/anton/milestones{/number}","notifications_url":"https://api.github.com/repos/laterpay/anton/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laterpay/anton/labels{/name}","releases_url":"https://api.github.com/repos/laterpay/anton/releases{/id}","created_at":"2012-11-26T12:08:21Z","updated_at":"2015-04-09T16:00:15Z","pushed_at":"2015-04-24T14:50:25Z","git_url":"git://github.com/laterpay/anton.git","ssh_url":"git@github.com:laterpay/anton.git","clone_url":"https://github.com/laterpay/anton.git","svn_url":"https://github.com/laterpay/anton","homepage":"http://www.youtube.com/watch?v=D6hwDOnZzpc","size":1512,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":10,"forks":2,"open_issues":10,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/laterpay/anton/pulls/44"},"html":{"href":"https://github.com/laterpay/anton/pull/44"},"issue":{"href":"https://api.github.com/repos/laterpay/anton/issues/44"},"comments":{"href":"https://api.github.com/repos/laterpay/anton/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/laterpay/anton/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/laterpay/anton/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/laterpay/anton/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/laterpay/anton/statuses/aa7a3d7f173ce128b4be0507aa1bbb8473541ed0"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"doismellburning","id":817118,"avatar_url":"https://avatars.githubusercontent.com/u/817118?v=3","gravatar_id":"","url":"https://api.github.com/users/doismellburning","html_url":"https://github.com/doismellburning","followers_url":"https://api.github.com/users/doismellburning/followers","following_url":"https://api.github.com/users/doismellburning/following{/other_user}","gists_url":"https://api.github.com/users/doismellburning/gists{/gist_id}","starred_url":"https://api.github.com/users/doismellburning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doismellburning/subscriptions","organizations_url":"https://api.github.com/users/doismellburning/orgs","repos_url":"https://api.github.com/users/doismellburning/repos","events_url":"https://api.github.com/users/doismellburning/events{/privacy}","received_events_url":"https://api.github.com/users/doismellburning/received_events","type":"User","site_admin":false},"comments":11,"review_comments":1,"commits":5,"additions":192,"deletions":70,"changed_files":2}}