强文 我正在编写一个python蜘蛛编码,我使用mongo数据库来存储网页的html和crawl_queue_list。起初,它运行良好,我可以创建与mongodb的连接(&#39 ; localhost',20717)并获取或设置项目。但是,大约3小时后,它会引发异常。我应该怎么处理它?!!
我的问题和一些存在的问题之间的区别在于,在我的程序开始时,它没问题!一切运行良好。我只是睡了几个小时后,我的mongodb拒绝任何连接。我键入的终端&m ;; mongod -dbpath。'表明已经杀死了(中文,意味着它已被杀死)。我不知道mongodb发生了什么事。我的电脑存储空间已经足够了
Exception in thread Thread-72:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/lowen/PycharmProjects/nookDemo/process_crawler.py", line 44, in process_queue
html = D(url)
File "/home/lowen/PycharmProjects/nookDemo/downloader.py", line 49, in __call__
self.cache[url] = result
File "/home/lowen/PycharmProjects/nookDemo/mongo_cache.py", line 76, in __setitem__
self.db.webpage.update({'_id': url}, {'$set': record}, upsert=True)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 2242, in update
with self._socket_for_writes() as sock_info:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 762, in _get_socket
server = self._get_topology().select_server(selector)
File "/usr/local/lib/python2.7/dist-packages/pymongo/topology.py", line 210, in select_server
address))
File "/usr/local/lib/python2.7/dist-packages/pymongo/topology.py", line 186, in select_servers
self._error_message(selector))
ServerSelectionTimeoutError:localhost:27017:[Errno 111]拒绝连接