{"action":"created","issue":{"url":"https://api.github.com/repos/marioroy/mce-perl/issues/3","repository_url":"https://api.github.com/repos/marioroy/mce-perl","labels_url":"https://api.github.com/repos/marioroy/mce-perl/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/marioroy/mce-perl/issues/3/comments","events_url":"https://api.github.com/repos/marioroy/mce-perl/issues/3/events","html_url":"https://github.com/marioroy/mce-perl/issues/3","id":173844009,"number":3,"title":"How to end mce_loop_f execution early without exiting calling program.","user":{"login":"akotlar","id":5543229,"avatar_url":"https://avatars.githubusercontent.com/u/5543229?v=3","gravatar_id":"","url":"https://api.github.com/users/akotlar","html_url":"https://github.com/akotlar","followers_url":"https://api.github.com/users/akotlar/followers","following_url":"https://api.github.com/users/akotlar/following{/other_user}","gists_url":"https://api.github.com/users/akotlar/gists{/gist_id}","starred_url":"https://api.github.com/users/akotlar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akotlar/subscriptions","organizations_url":"https://api.github.com/users/akotlar/orgs","repos_url":"https://api.github.com/users/akotlar/repos","events_url":"https://api.github.com/users/akotlar/events{/privacy}","received_events_url":"https://api.github.com/users/akotlar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-08-29T18:48:27Z","updated_at":"2016-09-01T02:38:39Z","closed_at":null,"body":"Trying to exit mce_loop_f early, to return to a long-running perl program that calls the function that contains the mce_loop_f. I've used a synchronized, shared variable, which each worker checks at the start of the loop; however $mce->shutdown() from within a worker results in re-spawning of workers, the loop doesn't end until the rest of the file is read\r\n\r\nAnother approach was to handle cleanup in the parent process, and then die/croak or use MCE::Signal->stop_and_exit(\"TERM\")  (or \"INT\"). In the former solution, control returns back to the caller, but subsequent calls to the function bearing mce_loop_f results in \"MCE::shutdown: method is not allowed...\". \r\n\r\nUsing MCE::Signal->stop_and_exit exist the entire program, including the caller. I just want to break early from the function that calls mce_loop_f, not exit the program. Have tried to use SIG{TERM} to \"catch\", but this doesn't prevent the program from exiting, just allows me to run a function before exiting. Similarly, wrapping in Try::Catch doesn't prevent exit. I am clearly new to the use of sigtrap or SIG{...} handlers.\r\n\r\nWondering if sigtrap is the recommended way. It would be nice if there were just a way to use MCE::Signal->stop_and_exit , or MCE::Loop::finish to end mce_loop_f, and continue execution to the code below it.\r\n\r\nThank you."},"comment":{"url":"https://api.github.com/repos/marioroy/mce-perl/issues/comments/243960071","html_url":"https://github.com/marioroy/mce-perl/issues/3#issuecomment-243960071","issue_url":"https://api.github.com/repos/marioroy/mce-perl/issues/3","id":243960071,"user":{"login":"akotlar","id":5543229,"avatar_url":"https://avatars.githubusercontent.com/u/5543229?v=3","gravatar_id":"","url":"https://api.github.com/users/akotlar","html_url":"https://github.com/akotlar","followers_url":"https://api.github.com/users/akotlar/followers","following_url":"https://api.github.com/users/akotlar/following{/other_user}","gists_url":"https://api.github.com/users/akotlar/gists{/gist_id}","starred_url":"https://api.github.com/users/akotlar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akotlar/subscriptions","organizations_url":"https://api.github.com/users/akotlar/orgs","repos_url":"https://api.github.com/users/akotlar/repos","events_url":"https://api.github.com/users/akotlar/events{/privacy}","received_events_url":"https://api.github.com/users/akotlar/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T02:38:39Z","updated_at":"2016-09-01T02:38:39Z","body":"Thank you. This is very helpful. Given your tests it is clearly something in the rest of my application, although I'm not sure what could cause the behavior that I'm seeing. I think we can consider this issue closed :)"}}
{"actor":{"display_login":"akotlar"}}