{"action":"created","issue":{"url":"https://api.github.com/repos/iarna/abraxas/issues/16","labels_url":"https://api.github.com/repos/iarna/abraxas/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/iarna/abraxas/issues/16/comments","events_url":"https://api.github.com/repos/iarna/abraxas/issues/16/events","html_url":"https://github.com/iarna/abraxas/issues/16","id":115611859,"number":16,"title":"Immediate disconnect breaks worker's task.end","user":{"login":"amv","id":102912,"avatar_url":"https://avatars.githubusercontent.com/u/102912?v=3","gravatar_id":"","url":"https://api.github.com/users/amv","html_url":"https://github.com/amv","followers_url":"https://api.github.com/users/amv/followers","following_url":"https://api.github.com/users/amv/following{/other_user}","gists_url":"https://api.github.com/users/amv/gists{/gist_id}","starred_url":"https://api.github.com/users/amv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amv/subscriptions","organizations_url":"https://api.github.com/users/amv/orgs","repos_url":"https://api.github.com/users/amv/repos","events_url":"https://api.github.com/users/amv/events{/privacy}","received_events_url":"https://api.github.com/users/amv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-06T23:30:50Z","updated_at":"2015-12-21T22:53:22Z","closed_at":null,"body":"I am doing workers that do one task and then exit. In effect I want to do this:\r\n\r\n    client.registerWorker( 'success-function', {}, function( task ) {\r\n        task.end(\"success!\");\r\n        client.disconnect();\r\n    } );\r\n\r\nHowever when I do this, the worker never seems to send a success message to the gearman server.\r\n\r\nI hackishly solved the problem by adding \"nextTick\" timeout before disconnecting:\r\n\r\n    client.registerWorker( 'success-function', {}, function( task ) {\r\n        task.end(\"success!\");\r\n        setTimeout( function() { client.disconnect(); }, 0 );\r\n    } );\r\n\r\nDo you think this would warrant a fix? I'm personally not sure wether it is evident for everyone that calling task.end does not actually put the response to the current buffers, and that calling disconnect at the end of the handler causes the contents of the buffers to be checked before the worker function can put it's stuff to the queue (which I would think causes this behaviour, haven't checked yet).\r\n\r\nMaybe just moving the disconnect queue checking to nextTick would help?\r\n\r\nIs there anything I could do to help with this?"},"comment":{"url":"https://api.github.com/repos/iarna/abraxas/issues/comments/166446018","html_url":"https://github.com/iarna/abraxas/issues/16#issuecomment-166446018","issue_url":"https://api.github.com/repos/iarna/abraxas/issues/16","id":166446018,"user":{"login":"amv","id":102912,"avatar_url":"https://avatars.githubusercontent.com/u/102912?v=3","gravatar_id":"","url":"https://api.github.com/users/amv","html_url":"https://github.com/amv","followers_url":"https://api.github.com/users/amv/followers","following_url":"https://api.github.com/users/amv/following{/other_user}","gists_url":"https://api.github.com/users/amv/gists{/gist_id}","starred_url":"https://api.github.com/users/amv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amv/subscriptions","organizations_url":"https://api.github.com/users/amv/orgs","repos_url":"https://api.github.com/users/amv/repos","events_url":"https://api.github.com/users/amv/events{/privacy}","received_events_url":"https://api.github.com/users/amv/received_events","type":"User","site_admin":false},"created_at":"2015-12-21T22:53:22Z","updated_at":"2015-12-21T22:53:22Z","body":"Actually.. What I am aiming to achieve with this is that the worker would execute it's job only once.. So is there a way to \"disable\" the worker somehow or should this jst be a part of the disconnect call? I would not want the worker to post a GRAB_JOB message to the server as part of it's ```finish``` callback just before disconnecting..\r\n\r\nI guess i could unregister my function after execution but it sounds a bit wasteful to send unregister messages for a worker that is just about to disconnect anyway..\r\n\r\nNot sure if any of this is relevant.. Just voicing my concerns :)"}}