just drop auto analysis requests silenty when queue is full
parent
5140740a0c
commit
3b16ffac99
|
@ -35,8 +35,10 @@ object Ai extends LilaController {
|
|||
initialFen = get("initialFen", req),
|
||||
requestedByHuman = getBool("human", req),
|
||||
variant = requestVariant(req)
|
||||
).effectFold(
|
||||
err => WS.url(s"$replyToUrl/err").post(err.toString),
|
||||
).effectFold({
|
||||
case lila.ai.Queue.FullException => logwarn("Dropping analyse request, queue is full")
|
||||
case err => WS.url(s"$replyToUrl/err").post(err.toString)
|
||||
},
|
||||
infos => WS.url(replyToUrl).post(lila.analyse.Info encodeList infos)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -58,15 +58,15 @@ private[ai] final class Queue(config: Config) extends Actor {
|
|||
tasks += Task(req, sender, timeout)
|
||||
}
|
||||
|
||||
case FullAnalReq(moves, fen, requestedByHuman, variant) if (requestedByHuman || tasks.size < maxTasks) =>
|
||||
case FullAnalReq(moves, fen, human, variant) if (human || tasks.size < maxTasks) =>
|
||||
val mrSender = sender
|
||||
val size = moves.size
|
||||
val startedAtPly = fen.flatMap(chess.format.Forsyth.getPly)
|
||||
implicit val timeout = makeTimeout {
|
||||
if (requestedByHuman) 1.hour else 24.hours
|
||||
if (human) 1.hour else 24.hours
|
||||
}
|
||||
val futures = (0 to size) map moves.take map { serie =>
|
||||
self ? AnalReq(serie, fen, size, requestedByHuman, variant) mapTo manifest[Option[Evaluation]]
|
||||
self ? AnalReq(serie, fen, size, human, variant) mapTo manifest[Option[Evaluation]]
|
||||
}
|
||||
Future.fold(futures)(Vector[Option[Evaluation]]())(_ :+ _) addFailureEffect {
|
||||
case e => mrSender ! Status.Failure(e)
|
||||
|
@ -74,7 +74,11 @@ private[ai] final class Queue(config: Config) extends Actor {
|
|||
mrSender ! Evaluation.toInfos(results.toList.map(_ | Evaluation.empty), moves, ~startedAtPly)
|
||||
}
|
||||
|
||||
case r: FullAnalReq =>
|
||||
sender ! Status.Failure(new Exception("analysis queue is full"))
|
||||
case r: FullAnalReq => sender ! Status.Failure(Queue.FullException)
|
||||
}
|
||||
}
|
||||
|
||||
object Queue {
|
||||
|
||||
case object FullException extends Exception("Analysis queue is full")
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ private[ai] final class Server(
|
|||
implicit val timeout = makeTimeout {
|
||||
if (requestedByHuman) 1.hour else 24.hours
|
||||
}
|
||||
(queue ? FullAnalReq(uciMoves take config.analyseMaxPlies, initialFen map chess960Fen, requestedByHuman, variant)) mapTo manifest[List[Info]]
|
||||
queue ? FullAnalReq(uciMoves take config.analyseMaxPlies, initialFen map chess960Fen, requestedByHuman, variant) mapTo manifest[List[Info]]
|
||||
}
|
||||
|
||||
private def chess960Fen(fen: String) = (Forsyth << fen).fold(fen) { situation =>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package lila
|
||||
|
||||
package object ai extends PackageObject with WithPlay
|
||||
package object ai extends PackageObject with WithPlay
|
||||
|
|
Loading…
Reference in New Issue