summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJedrzej Nowak <pigmej@gmail.com>2018-09-02 01:49:03 +0200
committerJedrzej Nowak <pigmej@gmail.com>2018-09-02 01:49:03 +0200
commitac066c5db0d04ebc40180ba6e10bcde7a305198c (patch)
treeabd4936412a9be4a4407b1b270df8d1c570267e8
parentd06da9ccf01d41d06849f890e2821b8e791535ac (diff)
downloadNim-ac066c5db0d04ebc40180ba6e10bcde7a305198c.tar.gz
Handle fut.failed in asyncdispatch.WithTimeout
Fixes: #8839
-rw-r--r--lib/pure/asyncdispatch.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim
index 093bf58af..820f34703 100644
--- a/lib/pure/asyncdispatch.nim
+++ b/lib/pure/asyncdispatch.nim
@@ -1536,7 +1536,11 @@ proc withTimeout*[T](fut: Future[T], timeout: int): Future[bool] =
   var timeoutFuture = sleepAsync(timeout)
   fut.callback =
     proc () =
-      if not retFuture.finished: retFuture.complete(true)
+      if not retFuture.finished:
+        if fut.failed:
+          retFuture.fail(fut.error)
+        else:
+          retFuture.complete(true)
   timeoutFuture.callback =
     proc () =
       if not retFuture.finished: retFuture.complete(false)
34'>134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225