Thanks dom96, when I try to download using httpclient.download file I get 
    
    
     Error: 'threadFunc' is not GC-safe as it accesses 'defaultSSLContext' 
which is a global using GC'ed memory

I've never used threads before, so my scripting may be wrong, here is my 
attempt at it:
    
    
    import locks
    import httpclient
    var L: Lock
    proc threadFunc(interval: tuple[url, output: string]) {.thread.} =
      acquire(L) # lock stdout
      echo interval.url
      downloadFile(interval.url, interval.output)
      #echo interval.b
      release(L)
    initLock(L)
    var thread: Thread[tuple[url, output: string]]
    createThread(thread, threadFunc, 
("http://s2.q4cdn.com/242125233/files/doc_downloads/test.pdf";, "test.pdf"))
    joinThread(thread)
    

It's roughly based on the example here: 
[http://nim-lang.org/docs/threads.html](http://forum.nim-lang.org///nim-lang.org/docs/threads.html)

I have yet to try the AsyncHttpServer method, I'll have to try that one next. 

Reply via email to