The following awaits forever, I think. How do I specify a timeout?
await(new Job<Long>() {
@Override
public Long doJobWithResult() throws Exception {
...
}
}.now());
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Implementing a timeout which kills a thread is actually a pretty difficult thing to do generically since you’d need to use Thread.stop() or something else horrid like that which might not clean up when it dies. The nicer way to do it is have the timeout set a flag in your long job that makes it stop processing and return sooner. Or alternatively, you let the long job continue and just render a response on the timeout.
Here is a testcase that does what you want:
https://github.com/playframework/play/blob/1.3.x/samples-and-tests/just-test-cases/app/controllers/WithContinuations.java#L73