From a8df0900713a1a56cffca8774bc137a6e781877e Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Thu, 15 Jun 2017 14:29:28 +0300 Subject: [PATCH] Fix httpcache leveldb tests: gc.collect after del LevelDB does not have "official" close method, so we have to rely on garbage collection to close it. --- scrapy/extensions/httpcache.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scrapy/extensions/httpcache.py b/scrapy/extensions/httpcache.py index 2fb4b6a15..648b32ec7 100644 --- a/scrapy/extensions/httpcache.py +++ b/scrapy/extensions/httpcache.py @@ -13,7 +13,7 @@ from scrapy.responsetypes import responsetypes from scrapy.utils.request import request_fingerprint from scrapy.utils.project import data_path from scrapy.utils.httpobj import urlparse_cached -from scrapy.utils.python import to_bytes, to_unicode +from scrapy.utils.python import to_bytes, to_unicode, garbage_collect logger = logging.getLogger(__name__) @@ -362,6 +362,7 @@ class LeveldbCacheStorage(object): # avoid them being removed in storages with timestamp-based autoremoval. self.db.CompactRange() del self.db + garbage_collect() def retrieve_response(self, spider, request): data = self._read_data(spider, request)