0

strong text i was coding an python spider,and i use mongo database to storage the webpage's html and the crawl_queue_list.At first ,it runs well,i could create connection to the mongodb('localhost',20717) and get or set items to it .However, after about 3 hours,it raise an Exception. How should i deal with it?!!

the difference between my question and some exist question is that at the begining of my program,it's ok!everything runs well.I just go to a sleep and after few hours,my mongodb refused any connection.The terminal that i type 'mongod -dbpath .' show that '已杀死'(chinese,means that it had beng killed).i don't know what happened to mongodb.Alos my computer's storage is enough

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] Connection refused

lowen tao
  • 1
  • 2
  • and when i was stopped,i tried **bold** `./mongo `,i still could not get connection to it unless i shut down my computer and retried – lowen tao Oct 30 '16 at 06:14
  • This means something happened and your server has crashed. Once it crashes, it doesn't restart by itself and will start refusing connections. – Burhan Khalid Oct 30 '16 at 06:30

0 Answers0