1

我正在 Play 框架中开发一种元启发式算法,并且必须有一个无限期的超时。加载一个小时后,我收到以下错误:

[AskTimeoutException:超时]

! @6g40d7af9 - Internal server error, for (GET) [/planificar] ->

play.api.Application$$anon$1: Execution exception[[AskTimeoutException: Timed out]]
    at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.1]
    at play.api.DefaultApplication.handleError(Application.scala:383) ~[play_2.10.jar:2.1.1]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:144) ~[play_2.10.jar:2.1.1]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:140) ~[play_2.10.jar:2.1.1]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) ~[play_2.10.jar:2.1.1]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) ~[play_2.10.jar:2.1.1]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend$1$$anonfun$apply$1.apply(Promise.scala:104) ~[play_2.10.jar:2.1.1]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[scala-library.jar:na]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[scala-library.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]
akka.pattern.AskTimeoutException: Timed out
    at akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:310) ~[akka-actor_2.10.jar:na]
    at akka.actor.DefaultScheduler$$anon$8.run(Scheduler.scala:193) ~[akka-actor_2.10.jar:na]
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:137) ~[akka-actor_2.10.jar:na]
    at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1417) ~[scala-library.jar:na]
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262) ~[scala-library.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) ~[scala-library.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1478) ~[scala-library.jar:na]
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104) ~[scala-library.jar:na]

有没有办法解决这个问题?谢谢。

编辑:

这是我的控制器

public static Result planificar() {
        Carga.cargarGlobales();
        Moacs moacs = new Moacs(cargarParametros());
        moacs.ejecutar(); // metaheuristics algorithm
        List<Solucion> soluciones =  moacs.getConjuntoPareto();            
        return ok(soluciones);
    }
4

2 回答 2

2

你应该使它成为一个异步控制器:http ://www.playframework.com/documentation/2.2.x/JavaAsync

于 2013-10-26T14:41:45.623 回答
0

您可以将 Timeout 设置为一个非常大的值。从 Scala文档中,范围FiniteDuration仅限于 +-(2^63-1)ns,大约是 292 年。

例如,可以这样做:

(someActor ? someMsg)(365 Days).map { x => .... }
于 2013-10-26T02:33:15.847 回答