Fix dangling file descriptor in FeedExporter when FEED_STORE_EMPTY is False (#4023)

This commit is contained in:
Adrián Chaves 2019-10-22 15:12:52 +02:00 committed by GitHub
parent 5d75ed4cba
commit 1d5c270ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -242,7 +242,9 @@ class FeedExporter(object):
def close_spider(self, spider):
slot = self.slot
if not slot.itemcount and not self.store_empty:
return
# We need to call slot.storage.store nonetheless to get the file
# properly closed.
return defer.maybeDeferred(slot.storage.store, slot.file)
if self._exporting:
slot.exporter.finish_exporting()
self._exporting = False

View File

@ -417,7 +417,7 @@ class FeedExportTest(unittest.TestCase):
content = f.read()
finally:
shutil.rmtree(tmpdir, ignore_errors=True)
shutil.rmtree(tmpdir)
defer.returnValue(content)