From 5a08cf3b9606bf77ef02a37dca1e2bc76f74558f Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Fri, 2 Sep 2016 00:22:22 +0300 Subject: [PATCH] Fix test_start_requests_errors for PyPy Twisted prints errors in DebugInfo.__del__, but PyPy does not run gc.collect() on exit: http://doc.pypy.org/en/latest/cpython_differences.html?highlight=gc.collect#differences-related-to-garbage-collection-strategies --- scrapy/cmdline.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scrapy/cmdline.py b/scrapy/cmdline.py index e4dc7f2de..b546d030e 100644 --- a/scrapy/cmdline.py +++ b/scrapy/cmdline.py @@ -4,6 +4,7 @@ import optparse import cProfile import inspect import pkg_resources +import gc import scrapy from scrapy.crawler import CrawlerProcess @@ -165,4 +166,9 @@ def _run_command_profiled(cmd, args, opts): p.dump_stats(opts.profile) if __name__ == '__main__': - execute() + try: + execute() + finally: + # Twisted prints errors in DebugInfo.__del__, but PyPy does not run gc.collect() + # on exit: http://doc.pypy.org/en/latest/cpython_differences.html?highlight=gc.collect#differences-related-to-garbage-collection-strategies + gc.collect()