Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Remove Guppy-specific code and documentation (#4343)

sakshamb2113533131a30fa9
diff --git a/docs/topics/leaks.rst b/docs/topics/leaks.rst
index 4ee447065..ceb708c7e 100644
--- a/docs/topics/leaks.rst
+++ b/docs/topics/leaks.rst
@@ -17,8 +17,8 @@ what is known as a "memory leak".
To help debugging memory leaks, Scrapy provides a built-in mechanism for
tracking objects references called :ref:`trackref <topics-leaks-trackrefs>`,
-and you can also use a third-party library called :ref:`Guppy
-<topics-leaks-guppy>` for more advanced memory debugging (see below for more
+and you can also use a third-party library called :ref:`muppy
+<topics-leaks-muppy>` for more advanced memory debugging (see below for more
info). Both mechanisms must be used from the :ref:`Telnet Console
<topics-telnetconsole>`.
@@ -193,9 +193,9 @@ Here are the functions available in the :mod:`~scrapy.utils.trackref` module.
``None`` if none is found. Use :func:`print_live_refs` first to get a list
of all tracked live objects per class name.
-.. _topics-leaks-guppy:
+.. _topics-leaks-muppy:
-Debugging memory leaks with Guppy
+Debugging memory leaks with muppy
=================================
``trackref`` provides a very convenient mechanism for tracking down memory
@@ -203,63 +203,9 @@ leaks, but it only keeps track of the objects that are more likely to cause
memory leaks (Requests, Responses, Items, and Selectors). However, there are
other cases where the memory leaks could come from other (more or less obscure)
objects. If this is your case, and you can't find your leaks using ``trackref``,
-you still have another resource: the `Guppy library`_.
-If you're using Python3, see :ref:`topics-leaks-muppy`.
-
-.. _Guppy library: https://pypi.org/project/guppy/
-
-If you use ``pip``, you can install Guppy with the following command::
-
- pip install guppy
-
-The telnet console also comes with a built-in shortcut (``hpy``) for accessing
-Guppy heap objects. Here's an example to view all Python objects available in
-the heap using Guppy:
-
->>> x = hpy.heap()
->>> x.bytype
-Partition of a set of 297033 objects. Total size = 52587824 bytes.
- Index Count % Size % Cumulative % Type
- 0 22307 8 16423880 31 16423880 31 dict
- 1 122285 41 12441544 24 28865424 55 str
- 2 68346 23 5966696 11 34832120 66 tuple
- 3 227 0 5836528 11 40668648 77 unicode
- 4 2461 1 2222272 4 42890920 82 type
- 5 16870 6 2024400 4 44915320 85 function
- 6 13949 5 1673880 3 46589200 89 types.CodeType
- 7 13422 5 1653104 3 48242304 92 list
- 8 3735 1 1173680 2 49415984 94 _sre.SRE_Pattern
- 9 1209 0 456936 1 49872920 95 scrapy.http.headers.Headers
-<1676 more rows. Type e.g. '_.more' to view.>
-
-You can see that most space is used by dicts. Then, if you want to see from
-which attribute those dicts are referenced, you could do:
-
->>> x.bytype[0].byvia
-Partition of a set of 22307 objects. Total size = 16423880 bytes.
- Index Count % Size % Cumulative % Referred Via:
- 0 10982 49 9416336 57 9416336 57 '.__dict__'
- 1 1820 8 2681504 16 12097840 74 '.__dict__', '.func_globals'
- 2 3097 14 1122904 7 13220744 80
- 3 990 4 277200 2 13497944 82 "['cookies']"
- 4 987 4 276360 2 13774304 84 "['cache']"
- 5 985 4 275800 2 14050104 86 "['meta']"
- 6 897 4 251160 2 14301264 87 '[2]'
- 7 1 0 196888 1 14498152 88 "['moduleDict']", "['modules']"
- 8 672 3 188160 1 14686312 89 "['cb_kwargs']"
- 9 27 0 155016 1 14841328 90 '[1]'
-<333 more rows. Type e.g. '_.more' to view.>
-
-As you can see, the Guppy module is very powerful but also requires some deep
-knowledge about Python internals. For more info about Guppy, refer to the
-`Guppy documentation`_.
-
-.. _Guppy documentation: http://guppy-pe.sourceforge.net/
+you still have another resource: the muppy library.
-.. _topics-leaks-muppy:
-Debugging memory leaks with muppy
-=================================
You can use muppy from `Pympler`_.
.. _Pympler: https://pypi.org/project/Pympler/
diff --git a/scrapy/extensions/telnet.py b/scrapy/extensions/telnet.py
index 26b214ee2..04ffd7235 100644
--- a/scrapy/extensions/telnet.py
+++ b/scrapy/extensions/telnet.py
@@ -26,11 +26,6 @@ from scrapy.utils.engine import print_engine_status
from scrapy.utils.reactor import listen_tcp
from scrapy.utils.decorators import defers
-try:
- import guppy
- hpy = guppy.hpy()
-except ImportError:
- hpy = None
logger = logging.getLogger(__name__)
@@ -110,7 +105,6 @@ class TelnetConsole(protocol.ServerFactory):
'est': lambda: print_engine_status(self.crawler.engine),
'p': pprint.pprint,
'prefs': print_live_refs,
- 'hpy': hpy,
'help': "This is Scrapy telnet console. For more info see: "
"https://docs.scrapy.org/en/latest/topics/telnetconsole.html",
}