From 27606aad1166afe3eebbee8dc365b1a122639e3c Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 30 Nov 2016 09:47:02 +0200 Subject: [PATCH] Fix #396 re-triggered issue The InteractiveShellEmbed class is a singleton and we need to drop the instance with its clear_instance() method to rebuild the instance from scratch with fresh environment for each subsequent Scrapy's shell drop in. --- scrapy/utils/console.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scrapy/utils/console.py b/scrapy/utils/console.py index 567fd51bc..1888d9599 100644 --- a/scrapy/utils/console.py +++ b/scrapy/utils/console.py @@ -15,6 +15,9 @@ def _embed_ipython_shell(namespace={}, banner=''): config = load_default_config() # Always use .instace() to ensure _instance propagation to all parents # this is needed for completion works well for new imports + # and clear the instance to always have the fresh env + # on repeated breaks like with inspect_response() + InteractiveShellEmbed.clear_instance() shell = InteractiveShellEmbed.instance( banner1=banner, user_ns=namespace, config=config) shell()