Sorry, I misread your code, I see that you are creating a new channel for each call. The function being called channel instead of createChannel or newChannel threw me :-)
With regards my original question, if I connect with shell instead of exec would I be correct in saying there is no way to tell when the end of the response has been received? Why does it not return the prompt?
Also, with your code, why does a poll time of 500ms work perfectly well with a command like "ls;sleep 5;ls;"? When I reduce the poll time to 100ms it times out.