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.
This commit is contained in:
Konstantin Lopuhin 2017-06-15 14:29:28 +03:00
parent b4eb60e527
commit a8df090071
1 changed files with 2 additions and 1 deletions

View File

@ -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)