t8982.nim 656 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. output: '''
  3. timeout
  4. runForever should throw ValueError, this is expected
  5. '''
  6. """
  7. import asyncdispatch
  8. proc failingAwaitable(p: int) {.async.} =
  9. await sleepAsync(500)
  10. if p > 0:
  11. raise newException(Exception, "my exception")
  12. proc main() {.async.} =
  13. let fut = failingAwaitable(1)
  14. try:
  15. await fut or sleepAsync(100)
  16. if fut.finished:
  17. echo "finished"
  18. else:
  19. echo "timeout"
  20. except:
  21. echo "failed"
  22. # Previously this would raise "An attempt was made to complete a Future more than once."
  23. try:
  24. asyncCheck main()
  25. runForever()
  26. except ValueError:
  27. echo "runForever should throw ValueError, this is expected"