the problem that the client cannot be shared to other download
    
    
    import httpClient, asyncdispatch
    
    proc download(url: string): Future[string] {.async.} =
        await newHttpClient().getContent(url)
    }
    
    proc downloadAll(urls: seq[string]) {.async.} =
      var asyncresult = newseq[Future[string]](urls.len)
      for i, url in urls:
        asyncresult[i] = download url
      await all(asyncresult)
    
    let urls = @[
      "http://127.0.0.1:5000/json";,
      "http://127.0.0.1:5001/json";,
      "http://127.0.0.1:5002/json";,
    ]
    waitFor downloadAll(urls)
    
    Run

Reply via email to