0

Is there an advisable way to stop a Play Framework promise? 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?

ticofab
  • 7,551
  • 13
  • 49
  • 90

2 Answers2

1

If the timeout period is too long just reduce the 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.

Community
  • 1
  • 1
korefn
  • 955
  • 6
  • 17
0

In the end I'm afraid the answer was no - there was no way of cancelling such promise before the timeout expires.

ticofab
  • 7,551
  • 13
  • 49
  • 90