[英]Can I stop a Play Framework promise?
Is there an advisable way to stop a Play Framework promise? 有没有可行的方法来停止Play框架承诺? For instance, 例如,
import play.api.libs.concurrent.Promise
val timeoutFuture = Promise.timeout({
Logger.info("timeout expired.")
}, myTimeoutValue)
What would be a good way to cancel this future before myTimeoutValue
expires? 在myTimeoutValue
过期之前取消此未来的好方法是什么?
If the timeout period is too long just reduce the myTimeoutValue
. 如果超时时间太长,请减少myTimeoutValue
。 If you wish to interrupt the execution the is a way shown here by completing a future. 如果你想中断执行的是一种这里显示通过完成一个未来。
This is however questionable way to do things since you can just ignore the result of your Promise/Future if it takes too long, but since you'll have to set a period for when its too long then its just as well as putting that as the timeout value. 但是,这是做事的方法,因为如果花费太长的时间您可以忽略承诺/未来的结果,但是由于必须设置一个时间段来确定其时间太长,然后将其放在超时值。
最后,恐怕答案是否定的-无法在超时到期之前取消此类承诺。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.