{"action":"created","comment":{"url":"https://api.github.com/repos/redding/dat-worker-pool/pulls/comments/44563619","id":44563619,"diff_hunk":"@@ -57,19 +57,18 @@ def decrement_worker_waiting\n       @workers_waiting.decrement\n     end\n \n+    def spawn_worker(worker)","path":"lib/dat-worker-pool/runner.rb","position":13,"original_position":13,"commit_id":"4f45194d693bcde38fc315033c981aebf5eb8537","original_commit_id":"4f45194d693bcde38fc315033c981aebf5eb8537","user":{"login":"kellyredding","id":82110,"avatar_url":"https://avatars.githubusercontent.com/u/82110?v=3","gravatar_id":"","url":"https://api.github.com/users/kellyredding","html_url":"https://github.com/kellyredding","followers_url":"https://api.github.com/users/kellyredding/followers","following_url":"https://api.github.com/users/kellyredding/following{/other_user}","gists_url":"https://api.github.com/users/kellyredding/gists{/gist_id}","starred_url":"https://api.github.com/users/kellyredding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellyredding/subscriptions","organizations_url":"https://api.github.com/users/kellyredding/orgs","repos_url":"https://api.github.com/users/kellyredding/repos","events_url":"https://api.github.com/users/kellyredding/events{/privacy}","received_events_url":"https://api.github.com/users/kellyredding/received_events","type":"User","site_admin":false},"body":"@jcredding we discussed renaming these to add/remove worker since the spawn/despawn doesn't necessarily apply anymore.","created_at":"2015-11-11T18:01:30Z","updated_at":"2015-11-11T18:01:30Z","html_url":"https://github.com/redding/dat-worker-pool/pull/34#discussion_r44563619","pull_request_url":"https://api.github.com/repos/redding/dat-worker-pool/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/redding/dat-worker-pool/pulls/comments/44563619"},"html":{"href":"https://github.com/redding/dat-worker-pool/pull/34#discussion_r44563619"},"pull_request":{"href":"https://api.github.com/repos/redding/dat-worker-pool/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/redding/dat-worker-pool/pulls/34","id":50408155,"html_url":"https://github.com/redding/dat-worker-pool/pull/34","diff_url":"https://github.com/redding/dat-worker-pool/pull/34.diff","patch_url":"https://github.com/redding/dat-worker-pool/pull/34.patch","issue_url":"https://api.github.com/repos/redding/dat-worker-pool/issues/34","number":34,"state":"open","locked":false,"title":"Change worker callbacks, instance exec and begin-rescue them","user":{"login":"jcredding","id":85966,"avatar_url":"https://avatars.githubusercontent.com/u/85966?v=3","gravatar_id":"","url":"https://api.github.com/users/jcredding","html_url":"https://github.com/jcredding","followers_url":"https://api.github.com/users/jcredding/followers","following_url":"https://api.github.com/users/jcredding/following{/other_user}","gists_url":"https://api.github.com/users/jcredding/gists{/gist_id}","starred_url":"https://api.github.com/users/jcredding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcredding/subscriptions","organizations_url":"https://api.github.com/users/jcredding/orgs","repos_url":"https://api.github.com/users/jcredding/repos","events_url":"https://api.github.com/users/jcredding/events{/privacy}","received_events_url":"https://api.github.com/users/jcredding/received_events","type":"User","site_admin":false},"body":"This changes the worker callbacks to be instance exec'd, wraps\r\nthe on-start and on-shutdown in begin-rescues and changes the\r\nworker to spawn itself with the runner when its started. This is\r\nto make the callbacks more consistent and safer (keep them from\r\nmessing up the worker behavior).\r\n\r\nThe worker callbacks are now instance exec'd instead of being\r\ncalled. This makes them more consistent with the `work!` method\r\nand lets them easily access the queue and params.  As part of this,\r\nthe internal methods and ivars for the workers behavior have been\r\nnamespaced to avoid user defined methods and ivars.\r\n\r\nThis also wraps the on-start an don-shutdown callbacks in\r\nbegin-rescues. This is to ensure that if they raise an error, the\r\non-error callbacks get called. This also tries to keep the errors\r\nfrom keeping workers from starting or shutting down incorrectly.\r\n\r\nFinally, this changes the worker to call a `spawn_worker` method\r\non the runner when it starts. This is consistent with how it calls\r\n`despawn_worker` when it shuts down. The `spawn_worker` adds the\r\nworker to the runners workers just like the `despawn_worker`\r\nremoves it. This makes sure we don't add the worker to the\r\ncollection before the thread has started and gotten to run (meaning\r\nits actually processing work).\r\n\r\n@kellyredding - Ready for review.","created_at":"2015-11-11T17:03:02Z","updated_at":"2015-11-11T18:01:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"729520a5b225d7129a0f197e94af1d4afa28480d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/redding/dat-worker-pool/pulls/34/commits","review_comments_url":"https://api.github.com/repos/redding/dat-worker-pool/pulls/34/comments","review_comment_url":"https://api.github.com/repos/redding/dat-worker-pool/pulls/comments{/number}","comments_url":"https://api.github.com/repos/redding/dat-worker-pool/issues/34/comments","statuses_url":"https://api.github.com/repos/redding/dat-worker-pool/statuses/4f45194d693bcde38fc315033c981aebf5eb8537","head":{"label":"redding:jcr-change-worker-callbacks","ref":"jcr-change-worker-callbacks","sha":"4f45194d693bcde38fc315033c981aebf5eb8537","user":{"login":"redding","id":2427810,"avatar_url":"https://avatars.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"repo":{"id":11273840,"name":"dat-worker-pool","full_name":"redding/dat-worker-pool","owner":{"login":"redding","id":2427810,"avatar_url":"https://avatars.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/redding/dat-worker-pool","description":"A simple thread pool for processing generic 'work'","fork":false,"url":"https://api.github.com/repos/redding/dat-worker-pool","forks_url":"https://api.github.com/repos/redding/dat-worker-pool/forks","keys_url":"https://api.github.com/repos/redding/dat-worker-pool/keys{/key_id}","collaborators_url":"https://api.github.com/repos/redding/dat-worker-pool/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/redding/dat-worker-pool/teams","hooks_url":"https://api.github.com/repos/redding/dat-worker-pool/hooks","issue_events_url":"https://api.github.com/repos/redding/dat-worker-pool/issues/events{/number}","events_url":"https://api.github.com/repos/redding/dat-worker-pool/events","assignees_url":"https://api.github.com/repos/redding/dat-worker-pool/assignees{/user}","branches_url":"https://api.github.com/repos/redding/dat-worker-pool/branches{/branch}","tags_url":"https://api.github.com/repos/redding/dat-worker-pool/tags","blobs_url":"https://api.github.com/repos/redding/dat-worker-pool/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/redding/dat-worker-pool/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/redding/dat-worker-pool/git/refs{/sha}","trees_url":"https://api.github.com/repos/redding/dat-worker-pool/git/trees{/sha}","statuses_url":"https://api.github.com/repos/redding/dat-worker-pool/statuses/{sha}","languages_url":"https://api.github.com/repos/redding/dat-worker-pool/languages","stargazers_url":"https://api.github.com/repos/redding/dat-worker-pool/stargazers","contributors_url":"https://api.github.com/repos/redding/dat-worker-pool/contributors","subscribers_url":"https://api.github.com/repos/redding/dat-worker-pool/subscribers","subscription_url":"https://api.github.com/repos/redding/dat-worker-pool/subscription","commits_url":"https://api.github.com/repos/redding/dat-worker-pool/commits{/sha}","git_commits_url":"https://api.github.com/repos/redding/dat-worker-pool/git/commits{/sha}","comments_url":"https://api.github.com/repos/redding/dat-worker-pool/comments{/number}","issue_comment_url":"https://api.github.com/repos/redding/dat-worker-pool/issues/comments{/number}","contents_url":"https://api.github.com/repos/redding/dat-worker-pool/contents/{+path}","compare_url":"https://api.github.com/repos/redding/dat-worker-pool/compare/{base}...{head}","merges_url":"https://api.github.com/repos/redding/dat-worker-pool/merges","archive_url":"https://api.github.com/repos/redding/dat-worker-pool/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/redding/dat-worker-pool/downloads","issues_url":"https://api.github.com/repos/redding/dat-worker-pool/issues{/number}","pulls_url":"https://api.github.com/repos/redding/dat-worker-pool/pulls{/number}","milestones_url":"https://api.github.com/repos/redding/dat-worker-pool/milestones{/number}","notifications_url":"https://api.github.com/repos/redding/dat-worker-pool/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/redding/dat-worker-pool/labels{/name}","releases_url":"https://api.github.com/repos/redding/dat-worker-pool/releases{/id}","created_at":"2013-07-09T05:32:00Z","updated_at":"2015-04-22T16:00:08Z","pushed_at":"2015-11-11T17:03:02Z","git_url":"git://github.com/redding/dat-worker-pool.git","ssh_url":"git@github.com:redding/dat-worker-pool.git","clone_url":"https://github.com/redding/dat-worker-pool.git","svn_url":"https://github.com/redding/dat-worker-pool","homepage":null,"size":764,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"base":{"label":"redding:master","ref":"master","sha":"4c38c441d298ba60c7001042837617b87a80a510","user":{"login":"redding","id":2427810,"avatar_url":"https://avatars.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"repo":{"id":11273840,"name":"dat-worker-pool","full_name":"redding/dat-worker-pool","owner":{"login":"redding","id":2427810,"avatar_url":"https://avatars.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/redding/dat-worker-pool","description":"A simple thread pool for processing generic 'work'","fork":false,"url":"https://api.github.com/repos/redding/dat-worker-pool","forks_url":"https://api.github.com/repos/redding/dat-worker-pool/forks","keys_url":"https://api.github.com/repos/redding/dat-worker-pool/keys{/key_id}","collaborators_url":"https://api.github.com/repos/redding/dat-worker-pool/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/redding/dat-worker-pool/teams","hooks_url":"https://api.github.com/repos/redding/dat-worker-pool/hooks","issue_events_url":"https://api.github.com/repos/redding/dat-worker-pool/issues/events{/number}","events_url":"https://api.github.com/repos/redding/dat-worker-pool/events","assignees_url":"https://api.github.com/repos/redding/dat-worker-pool/assignees{/user}","branches_url":"https://api.github.com/repos/redding/dat-worker-pool/branches{/branch}","tags_url":"https://api.github.com/repos/redding/dat-worker-pool/tags","blobs_url":"https://api.github.com/repos/redding/dat-worker-pool/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/redding/dat-worker-pool/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/redding/dat-worker-pool/git/refs{/sha}","trees_url":"https://api.github.com/repos/redding/dat-worker-pool/git/trees{/sha}","statuses_url":"https://api.github.com/repos/redding/dat-worker-pool/statuses/{sha}","languages_url":"https://api.github.com/repos/redding/dat-worker-pool/languages","stargazers_url":"https://api.github.com/repos/redding/dat-worker-pool/stargazers","contributors_url":"https://api.github.com/repos/redding/dat-worker-pool/contributors","subscribers_url":"https://api.github.com/repos/redding/dat-worker-pool/subscribers","subscription_url":"https://api.github.com/repos/redding/dat-worker-pool/subscription","commits_url":"https://api.github.com/repos/redding/dat-worker-pool/commits{/sha}","git_commits_url":"https://api.github.com/repos/redding/dat-worker-pool/git/commits{/sha}","comments_url":"https://api.github.com/repos/redding/dat-worker-pool/comments{/number}","issue_comment_url":"https://api.github.com/repos/redding/dat-worker-pool/issues/comments{/number}","contents_url":"https://api.github.com/repos/redding/dat-worker-pool/contents/{+path}","compare_url":"https://api.github.com/repos/redding/dat-worker-pool/compare/{base}...{head}","merges_url":"https://api.github.com/repos/redding/dat-worker-pool/merges","archive_url":"https://api.github.com/repos/redding/dat-worker-pool/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/redding/dat-worker-pool/downloads","issues_url":"https://api.github.com/repos/redding/dat-worker-pool/issues{/number}","pulls_url":"https://api.github.com/repos/redding/dat-worker-pool/pulls{/number}","milestones_url":"https://api.github.com/repos/redding/dat-worker-pool/milestones{/number}","notifications_url":"https://api.github.com/repos/redding/dat-worker-pool/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/redding/dat-worker-pool/labels{/name}","releases_url":"https://api.github.com/repos/redding/dat-worker-pool/releases{/id}","created_at":"2013-07-09T05:32:00Z","updated_at":"2015-04-22T16:00:08Z","pushed_at":"2015-11-11T17:03:02Z","git_url":"git://github.com/redding/dat-worker-pool.git","ssh_url":"git@github.com:redding/dat-worker-pool.git","clone_url":"https://github.com/redding/dat-worker-pool.git","svn_url":"https://github.com/redding/dat-worker-pool","homepage":null,"size":764,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/redding/dat-worker-pool/pulls/34"},"html":{"href":"https://github.com/redding/dat-worker-pool/pull/34"},"issue":{"href":"https://api.github.com/repos/redding/dat-worker-pool/issues/34"},"comments":{"href":"https://api.github.com/repos/redding/dat-worker-pool/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/redding/dat-worker-pool/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/redding/dat-worker-pool/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/redding/dat-worker-pool/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/redding/dat-worker-pool/statuses/4f45194d693bcde38fc315033c981aebf5eb8537"}}}}