Skip to content

Instantly share code, notes, and snippets.

@Yardanico
Created May 29, 2020 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yardanico/aa761852de6b32d8be623bc23b8171af to your computer and use it in GitHub Desktop.
Save Yardanico/aa761852de6b32d8be623bc23b8171af to your computer and use it in GitHub Desktop.
import asyncdispatch, httpclient
proc main {.async.} =
let a = newAsyncHttpClient()
let downFut = a.getContent("http://example.com")
if not await downFut.withTimeout(500):
echo "timeout!"
else:
echo downFut.read()
waitFor main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment