{"id":358,"date":"2022-01-20T09:44:28","date_gmt":"2022-01-20T01:44:28","guid":{"rendered":"http:\/\/47.98.165.52\/?p=358"},"modified":"2022-01-20T09:45:32","modified_gmt":"2022-01-20T01:45:32","slug":"python-%e5%a4%9a%e7%ba%bf%e7%a8%8b%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"\/?p=358","title":{"rendered":"python \u591a\u7ebf\u7a0b\u95ee\u9898"},"content":{"rendered":"<p><code>\u539f\u4ee3\u7801<\/code>:<\/p>\n<pre><code class=\"language-python\">while True:\n    conn, cur_pgsql = self.connectPGSQL()\n    sql = &quot;SELECT id,file_path FROM listed_companies.company_new_notice WHERE file_path_ is null and id &gt; {0}  limit 20&quot;.format(index)\n    cur_pgsql.execute(sql)\n    items = cur_pgsql.fetchall()\n    cur_pgsql.close()\n    conn.close()\n    with ThreadPoolExecutor(max_workers=20) as pool:\n        pool.map(self.downloadPDF, items)\n    index += 20<\/code><\/pre>\n<p>\u8fd0\u884c\u540e\u6ca1\u53cd\u5e94\uff0cCtrl+c\u540e\u5c31\u6709\u4e86\u5982\u4e0b\u62a5\u9519\u4fe1\u606f<\/p>\n<pre><code class=\"language-shell\">Traceback (most recent call last):\n  File &quot;company_new_notice.py&quot;, line 224, in &lt;module&gt;\n    spider.downloadUrl()\n  File &quot;company_new_notice.py&quot;, line 218, in downloadUrl\n    pool.map(self.downloadPDF, items)\n  File &quot;\/data01\/python3\/lib\/python3.6\/concurrent\/futures\/_base.py&quot;, line 581, in __exit__\n    self.shutdown(wait=True)\n  File &quot;\/data01\/python3\/lib\/python3.6\/concurrent\/futures\/thread.py&quot;, line 144, in shutdown\n    t.join()\n  File &quot;\/data01\/python3\/lib\/python3.6\/threading.py&quot;, line 1056, in join\n    self._wait_for_tstate_lock()\n  File &quot;\/data01\/python3\/lib\/python3.6\/threading.py&quot;, line 1072, in _wait_for_tstate_lock\n    elif lock.acquire(block, timeout):\nKeyboardInterrupt\n^CError in atexit._run_exitfuncs:\nTraceback (most recent call last):\n  File &quot;\/data01\/python3\/lib\/python3.6\/concurrent\/futures\/thread.py&quot;, line 39, in _python_exit\n    t.join()\n  File &quot;\/data01\/python3\/lib\/python3.6\/threading.py&quot;, line 1056, in join\n    self._wait_for_tstate_lock()\n  File &quot;\/data01\/python3\/lib\/python3.6\/threading.py&quot;, line 1072, in _wait_for_tstate_lock\n    elif lock.acquire(block, timeout):\nKeyboardInterrupt<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u4ee3\u7801: while True: conn, cur_pgsql = self.connectPGSQL() sql = &quot;S   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[32],"tags":[],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/358"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=358"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/358\/revisions"}],"predecessor-version":[{"id":359,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/358\/revisions\/359"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}