{"action":"created","comment":{"url":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/comments/23531633","id":23531633,"diff_hunk":"@@ -193,27 +210,48 @@ private function runJob(\\GearmanWorker $gearmanWorker, $objInstance, array $jobs\n         /**\n          * Executes GearmanWorker with all jobs defined\n          */\n-        while ($gearmanWorker->work()) {\n-\n-            $iterations--;\n-\n-            $event = new GearmanWorkExecutedEvent($jobs, $iterations, $gearmanWorker->returnCode());\n-            $this->eventDispatcher->dispatch(GearmanEvents::GEARMAN_WORK_EXECUTED, $event);\n-\n-            if ($gearmanWorker->returnCode() != GEARMAN_SUCCESS) {\n-\n-                break;\n+        while (\n+            @$gearmanWorker->work() ||\n+            $gearmanWorker->returnCode() == GEARMAN_IO_WAIT ||\n+            $gearmanWorker->returnCode() == GEARMAN_NO_JOBS\n+        ){\n+            if ($gearmanWorker->returnCode() == GEARMAN_SUCCESS) {\n+                $event = new GearmanWorkExecutedEvent($jobs, $iterations, $gearmanWorker->returnCode());\n+                $this->eventDispatcher->dispatch(GearmanEvents::GEARMAN_WORK_EXECUTED, $event);\n+\n+                $this->isRunning = false;\n+\n+                if ($this->isRequestedToStop) {\n+                    break;\n+                }\n+\n+                $iterations--;\n+\n+                /**\n+                 * Only finishes its execution if alive is false and iterations arrives to 0, or if\n+                 * signaled to stop\n+                 */\n+                if (!$alive && $iterations <= 0 && !$this->isRequestedToStop) {\n+                    break;\n+                }\n+\n+                continue;\n             }\n \n-            /**\n-             * Only finishes its execution if alive is false and iterations arrives to 0\n-             */\n-            if (!$alive && $iterations <= 0) {\n+            if (! @$gearmanWorker->wait()) {\n+                if ($gearmanWorker->returnCode() == GEARMAN_NO_ACTIVE_FDS)\n+                {\n+                    sleep(5);","path":"Service/GearmanExecute.php","position":83,"original_position":83,"commit_id":"db672b7dbf47b4ede15fdad366b0bd58be836d95","original_commit_id":"db672b7dbf47b4ede15fdad366b0bd58be836d95","user":{"login":"cotal","id":1677634,"avatar_url":"https://avatars.githubusercontent.com/u/1677634?v=3","gravatar_id":"","url":"https://api.github.com/users/cotal","html_url":"https://github.com/cotal","followers_url":"https://api.github.com/users/cotal/followers","following_url":"https://api.github.com/users/cotal/following{/other_user}","gists_url":"https://api.github.com/users/cotal/gists{/gist_id}","starred_url":"https://api.github.com/users/cotal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cotal/subscriptions","organizations_url":"https://api.github.com/users/cotal/orgs","repos_url":"https://api.github.com/users/cotal/repos","events_url":"https://api.github.com/users/cotal/events{/privacy}","received_events_url":"https://api.github.com/users/cotal/received_events","type":"User","site_admin":false},"body":"why 5 ? doc ?","created_at":"2015-01-26T14:02:27Z","updated_at":"2015-01-26T14:02:27Z","html_url":"https://github.com/lafourchette/GearmanBundle/pull/3#discussion_r23531633","pull_request_url":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/comments/23531633"},"html":{"href":"https://github.com/lafourchette/GearmanBundle/pull/3#discussion_r23531633"},"pull_request":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/3","id":28027242,"html_url":"https://github.com/lafourchette/GearmanBundle/pull/3","diff_url":"https://github.com/lafourchette/GearmanBundle/pull/3.diff","patch_url":"https://github.com/lafourchette/GearmanBundle/pull/3.patch","issue_url":"https://api.github.com/repos/lafourchette/GearmanBundle/issues/3","number":3,"state":"open","locked":false,"title":"Signalable worker","user":{"login":"dav-m85","id":1519726,"avatar_url":"https://avatars.githubusercontent.com/u/1519726?v=3","gravatar_id":"","url":"https://api.github.com/users/dav-m85","html_url":"https://github.com/dav-m85","followers_url":"https://api.github.com/users/dav-m85/followers","following_url":"https://api.github.com/users/dav-m85/following{/other_user}","gists_url":"https://api.github.com/users/dav-m85/gists{/gist_id}","starred_url":"https://api.github.com/users/dav-m85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dav-m85/subscriptions","organizations_url":"https://api.github.com/users/dav-m85/orgs","repos_url":"https://api.github.com/users/dav-m85/repos","events_url":"https://api.github.com/users/dav-m85/events{/privacy}","received_events_url":"https://api.github.com/users/dav-m85/received_events","type":"User","site_admin":false},"body":"Worker ends nicely on USR1 signal.","created_at":"2015-01-26T13:47:24Z","updated_at":"2015-01-26T14:02:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45d9ea028eb9fca230ab362e787abd17d5841bcc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/3/commits","review_comments_url":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/3/comments","review_comment_url":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/comments/{number}","comments_url":"https://api.github.com/repos/lafourchette/GearmanBundle/issues/3/comments","statuses_url":"https://api.github.com/repos/lafourchette/GearmanBundle/statuses/db672b7dbf47b4ede15fdad366b0bd58be836d95","head":{"label":"lafourchette:feature/signalable","ref":"feature/signalable","sha":"db672b7dbf47b4ede15fdad366b0bd58be836d95","user":{"login":"lafourchette","id":1640261,"avatar_url":"https://avatars.githubusercontent.com/u/1640261?v=3","gravatar_id":"","url":"https://api.github.com/users/lafourchette","html_url":"https://github.com/lafourchette","followers_url":"https://api.github.com/users/lafourchette/followers","following_url":"https://api.github.com/users/lafourchette/following{/other_user}","gists_url":"https://api.github.com/users/lafourchette/gists{/gist_id}","starred_url":"https://api.github.com/users/lafourchette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lafourchette/subscriptions","organizations_url":"https://api.github.com/users/lafourchette/orgs","repos_url":"https://api.github.com/users/lafourchette/repos","events_url":"https://api.github.com/users/lafourchette/events{/privacy}","received_events_url":"https://api.github.com/users/lafourchette/received_events","type":"Organization","site_admin":false},"repo":{"id":29673691,"name":"GearmanBundle","full_name":"lafourchette/GearmanBundle","owner":{"login":"lafourchette","id":1640261,"avatar_url":"https://avatars.githubusercontent.com/u/1640261?v=3","gravatar_id":"","url":"https://api.github.com/users/lafourchette","html_url":"https://github.com/lafourchette","followers_url":"https://api.github.com/users/lafourchette/followers","following_url":"https://api.github.com/users/lafourchette/following{/other_user}","gists_url":"https://api.github.com/users/lafourchette/gists{/gist_id}","starred_url":"https://api.github.com/users/lafourchette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lafourchette/subscriptions","organizations_url":"https://api.github.com/users/lafourchette/orgs","repos_url":"https://api.github.com/users/lafourchette/repos","events_url":"https://api.github.com/users/lafourchette/events{/privacy}","received_events_url":"https://api.github.com/users/lafourchette/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lafourchette/GearmanBundle","description":"GearmanBundle for Symfony2","fork":true,"url":"https://api.github.com/repos/lafourchette/GearmanBundle","forks_url":"https://api.github.com/repos/lafourchette/GearmanBundle/forks","keys_url":"https://api.github.com/repos/lafourchette/GearmanBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lafourchette/GearmanBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lafourchette/GearmanBundle/teams","hooks_url":"https://api.github.com/repos/lafourchette/GearmanBundle/hooks","issue_events_url":"https://api.github.com/repos/lafourchette/GearmanBundle/issues/events{/number}","events_url":"https://api.github.com/repos/lafourchette/GearmanBundle/events","assignees_url":"https://api.github.com/repos/lafourchette/GearmanBundle/assignees{/user}","branches_url":"https://api.github.com/repos/lafourchette/GearmanBundle/branches{/branch}","tags_url":"https://api.github.com/repos/lafourchette/GearmanBundle/tags","blobs_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lafourchette/GearmanBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/lafourchette/GearmanBundle/languages","stargazers_url":"https://api.github.com/repos/lafourchette/GearmanBundle/stargazers","contributors_url":"https://api.github.com/repos/lafourchette/GearmanBundle/contributors","subscribers_url":"https://api.github.com/repos/lafourchette/GearmanBundle/subscribers","subscription_url":"https://api.github.com/repos/lafourchette/GearmanBundle/subscription","commits_url":"https://api.github.com/repos/lafourchette/GearmanBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/lafourchette/GearmanBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/lafourchette/GearmanBundle/issues/comments/{number}","contents_url":"https://api.github.com/repos/lafourchette/GearmanBundle/contents/{+path}","compare_url":"https://api.github.com/repos/lafourchette/GearmanBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lafourchette/GearmanBundle/merges","archive_url":"https://api.github.com/repos/lafourchette/GearmanBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lafourchette/GearmanBundle/downloads","issues_url":"https://api.github.com/repos/lafourchette/GearmanBundle/issues{/number}","pulls_url":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/lafourchette/GearmanBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/lafourchette/GearmanBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lafourchette/GearmanBundle/labels{/name}","releases_url":"https://api.github.com/repos/lafourchette/GearmanBundle/releases{/id}","created_at":"2015-01-22T10:41:46Z","updated_at":"2015-01-23T10:26:04Z","pushed_at":"2015-01-26T13:55:46Z","git_url":"git://github.com/lafourchette/GearmanBundle.git","ssh_url":"git@github.com:lafourchette/GearmanBundle.git","clone_url":"https://github.com/lafourchette/GearmanBundle.git","svn_url":"https://github.com/lafourchette/GearmanBundle","homepage":"","size":544,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"lafourchette:2","ref":"2","sha":"54e9c581d068409308cc84083d24d1fd253a19cb","user":{"login":"lafourchette","id":1640261,"avatar_url":"https://avatars.githubusercontent.com/u/1640261?v=3","gravatar_id":"","url":"https://api.github.com/users/lafourchette","html_url":"https://github.com/lafourchette","followers_url":"https://api.github.com/users/lafourchette/followers","following_url":"https://api.github.com/users/lafourchette/following{/other_user}","gists_url":"https://api.github.com/users/lafourchette/gists{/gist_id}","starred_url":"https://api.github.com/users/lafourchette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lafourchette/subscriptions","organizations_url":"https://api.github.com/users/lafourchette/orgs","repos_url":"https://api.github.com/users/lafourchette/repos","events_url":"https://api.github.com/users/lafourchette/events{/privacy}","received_events_url":"https://api.github.com/users/lafourchette/received_events","type":"Organization","site_admin":false},"repo":{"id":29673691,"name":"GearmanBundle","full_name":"lafourchette/GearmanBundle","owner":{"login":"lafourchette","id":1640261,"avatar_url":"https://avatars.githubusercontent.com/u/1640261?v=3","gravatar_id":"","url":"https://api.github.com/users/lafourchette","html_url":"https://github.com/lafourchette","followers_url":"https://api.github.com/users/lafourchette/followers","following_url":"https://api.github.com/users/lafourchette/following{/other_user}","gists_url":"https://api.github.com/users/lafourchette/gists{/gist_id}","starred_url":"https://api.github.com/users/lafourchette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lafourchette/subscriptions","organizations_url":"https://api.github.com/users/lafourchette/orgs","repos_url":"https://api.github.com/users/lafourchette/repos","events_url":"https://api.github.com/users/lafourchette/events{/privacy}","received_events_url":"https://api.github.com/users/lafourchette/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lafourchette/GearmanBundle","description":"GearmanBundle for Symfony2","fork":true,"url":"https://api.github.com/repos/lafourchette/GearmanBundle","forks_url":"https://api.github.com/repos/lafourchette/GearmanBundle/forks","keys_url":"https://api.github.com/repos/lafourchette/GearmanBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lafourchette/GearmanBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lafourchette/GearmanBundle/teams","hooks_url":"https://api.github.com/repos/lafourchette/GearmanBundle/hooks","issue_events_url":"https://api.github.com/repos/lafourchette/GearmanBundle/issues/events{/number}","events_url":"https://api.github.com/repos/lafourchette/GearmanBundle/events","assignees_url":"https://api.github.com/repos/lafourchette/GearmanBundle/assignees{/user}","branches_url":"https://api.github.com/repos/lafourchette/GearmanBundle/branches{/branch}","tags_url":"https://api.github.com/repos/lafourchette/GearmanBundle/tags","blobs_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lafourchette/GearmanBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/lafourchette/GearmanBundle/languages","stargazers_url":"https://api.github.com/repos/lafourchette/GearmanBundle/stargazers","contributors_url":"https://api.github.com/repos/lafourchette/GearmanBundle/contributors","subscribers_url":"https://api.github.com/repos/lafourchette/GearmanBundle/subscribers","subscription_url":"https://api.github.com/repos/lafourchette/GearmanBundle/subscription","commits_url":"https://api.github.com/repos/lafourchette/GearmanBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/lafourchette/GearmanBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/lafourchette/GearmanBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/lafourchette/GearmanBundle/issues/comments/{number}","contents_url":"https://api.github.com/repos/lafourchette/GearmanBundle/contents/{+path}","compare_url":"https://api.github.com/repos/lafourchette/GearmanBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lafourchette/GearmanBundle/merges","archive_url":"https://api.github.com/repos/lafourchette/GearmanBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lafourchette/GearmanBundle/downloads","issues_url":"https://api.github.com/repos/lafourchette/GearmanBundle/issues{/number}","pulls_url":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/lafourchette/GearmanBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/lafourchette/GearmanBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lafourchette/GearmanBundle/labels{/name}","releases_url":"https://api.github.com/repos/lafourchette/GearmanBundle/releases{/id}","created_at":"2015-01-22T10:41:46Z","updated_at":"2015-01-23T10:26:04Z","pushed_at":"2015-01-26T13:55:46Z","git_url":"git://github.com/lafourchette/GearmanBundle.git","ssh_url":"git@github.com:lafourchette/GearmanBundle.git","clone_url":"https://github.com/lafourchette/GearmanBundle.git","svn_url":"https://github.com/lafourchette/GearmanBundle","homepage":"","size":544,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/3"},"html":{"href":"https://github.com/lafourchette/GearmanBundle/pull/3"},"issue":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/issues/3"},"comments":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/lafourchette/GearmanBundle/statuses/db672b7dbf47b4ede15fdad366b0bd58be836d95"}}}}