{"action":"closed","number":173,"pull_request":{"url":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls/173","id":41976758,"html_url":"https://github.com/SirCmpwn/RedditSharp/pull/173","diff_url":"https://github.com/SirCmpwn/RedditSharp/pull/173.diff","patch_url":"https://github.com/SirCmpwn/RedditSharp/pull/173.patch","issue_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/issues/173","number":173,"state":"closed","locked":false,"title":"Remove bug and race condition from EnforceRateLimit","user":{"login":"quadraticjames","id":6493915,"avatar_url":"https://avatars.githubusercontent.com/u/6493915?v=3","gravatar_id":"","url":"https://api.github.com/users/quadraticjames","html_url":"https://github.com/quadraticjames","followers_url":"https://api.github.com/users/quadraticjames/followers","following_url":"https://api.github.com/users/quadraticjames/following{/other_user}","gists_url":"https://api.github.com/users/quadraticjames/gists{/gist_id}","starred_url":"https://api.github.com/users/quadraticjames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quadraticjames/subscriptions","organizations_url":"https://api.github.com/users/quadraticjames/orgs","repos_url":"https://api.github.com/users/quadraticjames/repos","events_url":"https://api.github.com/users/quadraticjames/events{/privacy}","received_events_url":"https://api.github.com/users/quadraticjames/received_events","type":"User","site_admin":false},"body":"Not resetting _requestsThisBurst meant that after 30 calls to the Reddit API you would only be able to make one call per minute. I fixed this by resetting _requestsThisBurst to 0 when _burstStart is reset.\r\n\r\nNot making the method synchronized meant that there existed a race condition where more than 30 requests would be transmitted every 60 seconds. This can be exhibited by printing _requestsThisBurst on every EnforceRateLimit call and making a demo program that calls the API many times in parallel, for example:\r\n\r\nvar posts = reddit.GetSubreddit(\"askreddit\").Hot.Take(100);\r\nParallel.ForEach(posts, post =>\r\n{\r\n    var topCommentAuthor = post.Comments.FirstOrDefault().Author\r\n});","created_at":"2015-08-09T20:47:35Z","updated_at":"2015-08-09T20:48:38Z","closed_at":"2015-08-09T20:48:38Z","merged_at":"2015-08-09T20:48:38Z","merge_commit_sha":"dcc1a9968f5cb927d51e796b003154184273b913","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls/173/commits","review_comments_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls/173/comments","review_comment_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/issues/173/comments","statuses_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/statuses/725369d362e133d2b8a09bf1b47d76b905585ab2","head":{"label":"quadraticjames:master","ref":"master","sha":"725369d362e133d2b8a09bf1b47d76b905585ab2","user":{"login":"quadraticjames","id":6493915,"avatar_url":"https://avatars.githubusercontent.com/u/6493915?v=3","gravatar_id":"","url":"https://api.github.com/users/quadraticjames","html_url":"https://github.com/quadraticjames","followers_url":"https://api.github.com/users/quadraticjames/followers","following_url":"https://api.github.com/users/quadraticjames/following{/other_user}","gists_url":"https://api.github.com/users/quadraticjames/gists{/gist_id}","starred_url":"https://api.github.com/users/quadraticjames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quadraticjames/subscriptions","organizations_url":"https://api.github.com/users/quadraticjames/orgs","repos_url":"https://api.github.com/users/quadraticjames/repos","events_url":"https://api.github.com/users/quadraticjames/events{/privacy}","received_events_url":"https://api.github.com/users/quadraticjames/received_events","type":"User","site_admin":false},"repo":{"id":40448610,"name":"RedditSharp","full_name":"quadraticjames/RedditSharp","owner":{"login":"quadraticjames","id":6493915,"avatar_url":"https://avatars.githubusercontent.com/u/6493915?v=3","gravatar_id":"","url":"https://api.github.com/users/quadraticjames","html_url":"https://github.com/quadraticjames","followers_url":"https://api.github.com/users/quadraticjames/followers","following_url":"https://api.github.com/users/quadraticjames/following{/other_user}","gists_url":"https://api.github.com/users/quadraticjames/gists{/gist_id}","starred_url":"https://api.github.com/users/quadraticjames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quadraticjames/subscriptions","organizations_url":"https://api.github.com/users/quadraticjames/orgs","repos_url":"https://api.github.com/users/quadraticjames/repos","events_url":"https://api.github.com/users/quadraticjames/events{/privacy}","received_events_url":"https://api.github.com/users/quadraticjames/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/quadraticjames/RedditSharp","description":"Reddit API for .NET","fork":true,"url":"https://api.github.com/repos/quadraticjames/RedditSharp","forks_url":"https://api.github.com/repos/quadraticjames/RedditSharp/forks","keys_url":"https://api.github.com/repos/quadraticjames/RedditSharp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quadraticjames/RedditSharp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quadraticjames/RedditSharp/teams","hooks_url":"https://api.github.com/repos/quadraticjames/RedditSharp/hooks","issue_events_url":"https://api.github.com/repos/quadraticjames/RedditSharp/issues/events{/number}","events_url":"https://api.github.com/repos/quadraticjames/RedditSharp/events","assignees_url":"https://api.github.com/repos/quadraticjames/RedditSharp/assignees{/user}","branches_url":"https://api.github.com/repos/quadraticjames/RedditSharp/branches{/branch}","tags_url":"https://api.github.com/repos/quadraticjames/RedditSharp/tags","blobs_url":"https://api.github.com/repos/quadraticjames/RedditSharp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quadraticjames/RedditSharp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quadraticjames/RedditSharp/git/refs{/sha}","trees_url":"https://api.github.com/repos/quadraticjames/RedditSharp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quadraticjames/RedditSharp/statuses/{sha}","languages_url":"https://api.github.com/repos/quadraticjames/RedditSharp/languages","stargazers_url":"https://api.github.com/repos/quadraticjames/RedditSharp/stargazers","contributors_url":"https://api.github.com/repos/quadraticjames/RedditSharp/contributors","subscribers_url":"https://api.github.com/repos/quadraticjames/RedditSharp/subscribers","subscription_url":"https://api.github.com/repos/quadraticjames/RedditSharp/subscription","commits_url":"https://api.github.com/repos/quadraticjames/RedditSharp/commits{/sha}","git_commits_url":"https://api.github.com/repos/quadraticjames/RedditSharp/git/commits{/sha}","comments_url":"https://api.github.com/repos/quadraticjames/RedditSharp/comments{/number}","issue_comment_url":"https://api.github.com/repos/quadraticjames/RedditSharp/issues/comments{/number}","contents_url":"https://api.github.com/repos/quadraticjames/RedditSharp/contents/{+path}","compare_url":"https://api.github.com/repos/quadraticjames/RedditSharp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quadraticjames/RedditSharp/merges","archive_url":"https://api.github.com/repos/quadraticjames/RedditSharp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quadraticjames/RedditSharp/downloads","issues_url":"https://api.github.com/repos/quadraticjames/RedditSharp/issues{/number}","pulls_url":"https://api.github.com/repos/quadraticjames/RedditSharp/pulls{/number}","milestones_url":"https://api.github.com/repos/quadraticjames/RedditSharp/milestones{/number}","notifications_url":"https://api.github.com/repos/quadraticjames/RedditSharp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quadraticjames/RedditSharp/labels{/name}","releases_url":"https://api.github.com/repos/quadraticjames/RedditSharp/releases{/id}","created_at":"2015-08-09T19:58:03Z","updated_at":"2015-08-09T19:58:04Z","pushed_at":"2015-08-09T20:42:13Z","git_url":"git://github.com/quadraticjames/RedditSharp.git","ssh_url":"git@github.com:quadraticjames/RedditSharp.git","clone_url":"https://github.com/quadraticjames/RedditSharp.git","svn_url":"https://github.com/quadraticjames/RedditSharp","homepage":"","size":857,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"SirCmpwn:master","ref":"master","sha":"aad8878c2a11a1297cb9948e404f099eea4c6aac","user":{"login":"SirCmpwn","id":1310872,"avatar_url":"https://avatars.githubusercontent.com/u/1310872?v=3","gravatar_id":"","url":"https://api.github.com/users/SirCmpwn","html_url":"https://github.com/SirCmpwn","followers_url":"https://api.github.com/users/SirCmpwn/followers","following_url":"https://api.github.com/users/SirCmpwn/following{/other_user}","gists_url":"https://api.github.com/users/SirCmpwn/gists{/gist_id}","starred_url":"https://api.github.com/users/SirCmpwn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SirCmpwn/subscriptions","organizations_url":"https://api.github.com/users/SirCmpwn/orgs","repos_url":"https://api.github.com/users/SirCmpwn/repos","events_url":"https://api.github.com/users/SirCmpwn/events{/privacy}","received_events_url":"https://api.github.com/users/SirCmpwn/received_events","type":"User","site_admin":false},"repo":{"id":6785228,"name":"RedditSharp","full_name":"SirCmpwn/RedditSharp","owner":{"login":"SirCmpwn","id":1310872,"avatar_url":"https://avatars.githubusercontent.com/u/1310872?v=3","gravatar_id":"","url":"https://api.github.com/users/SirCmpwn","html_url":"https://github.com/SirCmpwn","followers_url":"https://api.github.com/users/SirCmpwn/followers","following_url":"https://api.github.com/users/SirCmpwn/following{/other_user}","gists_url":"https://api.github.com/users/SirCmpwn/gists{/gist_id}","starred_url":"https://api.github.com/users/SirCmpwn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SirCmpwn/subscriptions","organizations_url":"https://api.github.com/users/SirCmpwn/orgs","repos_url":"https://api.github.com/users/SirCmpwn/repos","events_url":"https://api.github.com/users/SirCmpwn/events{/privacy}","received_events_url":"https://api.github.com/users/SirCmpwn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SirCmpwn/RedditSharp","description":"Reddit API for .NET","fork":false,"url":"https://api.github.com/repos/SirCmpwn/RedditSharp","forks_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/forks","keys_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/teams","hooks_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/hooks","issue_events_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/issues/events{/number}","events_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/events","assignees_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/assignees{/user}","branches_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/branches{/branch}","tags_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/tags","blobs_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/git/refs{/sha}","trees_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/statuses/{sha}","languages_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/languages","stargazers_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/stargazers","contributors_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/contributors","subscribers_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/subscribers","subscription_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/subscription","commits_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/commits{/sha}","git_commits_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/git/commits{/sha}","comments_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/comments{/number}","issue_comment_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/issues/comments{/number}","contents_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/contents/{+path}","compare_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/merges","archive_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/downloads","issues_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/issues{/number}","pulls_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls{/number}","milestones_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/milestones{/number}","notifications_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/labels{/name}","releases_url":"https://api.github.com/repos/SirCmpwn/RedditSharp/releases{/id}","created_at":"2012-11-20T21:10:07Z","updated_at":"2015-08-07T20:11:23Z","pushed_at":"2015-08-09T20:48:38Z","git_url":"git://github.com/SirCmpwn/RedditSharp.git","ssh_url":"git@github.com:SirCmpwn/RedditSharp.git","clone_url":"https://github.com/SirCmpwn/RedditSharp.git","svn_url":"https://github.com/SirCmpwn/RedditSharp","homepage":"","size":2380,"stargazers_count":205,"watchers_count":205,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":117,"mirror_url":null,"open_issues_count":9,"forks":117,"open_issues":9,"watchers":205,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls/173"},"html":{"href":"https://github.com/SirCmpwn/RedditSharp/pull/173"},"issue":{"href":"https://api.github.com/repos/SirCmpwn/RedditSharp/issues/173"},"comments":{"href":"https://api.github.com/repos/SirCmpwn/RedditSharp/issues/173/comments"},"review_comments":{"href":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls/173/comments"},"review_comment":{"href":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SirCmpwn/RedditSharp/pulls/173/commits"},"statuses":{"href":"https://api.github.com/repos/SirCmpwn/RedditSharp/statuses/725369d362e133d2b8a09bf1b47d76b905585ab2"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"SirCmpwn","id":1310872,"avatar_url":"https://avatars.githubusercontent.com/u/1310872?v=3","gravatar_id":"","url":"https://api.github.com/users/SirCmpwn","html_url":"https://github.com/SirCmpwn","followers_url":"https://api.github.com/users/SirCmpwn/followers","following_url":"https://api.github.com/users/SirCmpwn/following{/other_user}","gists_url":"https://api.github.com/users/SirCmpwn/gists{/gist_id}","starred_url":"https://api.github.com/users/SirCmpwn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SirCmpwn/subscriptions","organizations_url":"https://api.github.com/users/SirCmpwn/orgs","repos_url":"https://api.github.com/users/SirCmpwn/repos","events_url":"https://api.github.com/users/SirCmpwn/events{/privacy}","received_events_url":"https://api.github.com/users/SirCmpwn/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"commits":1,"additions":4,"deletions":0,"changed_files":1}}