首页 文章

Clojure程序运行后无法完成

提问于
浏览
0

我的问题是执行我的clojure程序出乎意料的情况 .

我使用Ubuntu 14.04 x64,Lein和Clojure(都是最新版本) . 我已经完成了我的小项目(网络爬虫,只是为了学习clojure) . 它确实有用,我敢肯定('因为我在repl中运行它) .

好的,我正在尝试用终端中的lein运行它(看截图) . 它工作正常,然后打印经过的时间 . 但是,它正在等待一些事情 . 那就是问题所在 . 程序无法停止,也无法将控制权交还给ubuntu的终端 . 我第一次面对它,我以前的所有项目都是自己完成的 . 现在唯一的方法是“Ctrl C” . 在代码中,我使用“命令式”命令(doseq,do),文件i / o(带开放式读写器),代理(发送,等待)和“clj-http.client”来下载网页 . 它们是潜在的原因 .

这是我的“主要”:

(defn crawl-bunch [depth]
  (do
    (send-off urls visit-urls)
    (await urls)
    (renew-urls)
    (await urls)
    (send-off urls mark-used-urls)
    (await urls)
    (dec depth)))

(defn crawl [depth]
  (loop [i depth]
    (if (= i 0)
      (save-found-urls "out_urls.txt")
      (recur (crawl-bunch i)))))

(defn -main [& args]
  (time 
   (do
    (file-to-urls "urls.txt")
    (crawl 1))))

这里是完整的源代码 - 近100个字符串(/src/crawler/core.clj):https://github.com/ivanpetrov16130/crawler

请告诉我,如何解决?谢谢你的答案,请原谅我的语法,语法和逻辑错误 .

Image is full of sorrow."

1 回答

  • 2

    您需要运行shutdown-agents,以便代理程序使用的线程池关闭 .

相关问题