Hrm, try this as a workaround:
    
    
    import asyncdispatch, threadpool, os
    
    var started = false
    
    proc process() {.async.} =
      if started: return
      started = true
      echo "start process"
      while started:
        var client = newAsyncHttpClient()
        var resp = await client.getContent("http://google.com";)
        echo $len(resp)
        #doSomething
        client.close
        await sleepAsync(5000)
      echo "stop process"
    
    proc main() =
      var msg = spawn stdin.readLine()
      while true:
        if msg.isReady():
          case ^msg:
          of "stop": started = false
          of "start": asyncCheck process()
          of "bye":
            if started: echo"enter stop before" else: return
          else: echo"invalid command"
          msg = spawn stdin.readLine()
        if hasPendingOperations():
          poll(500)
        else:
          sleep(500)
    
    main()
    

Reply via email to