From d44d5c33040806821ae08bbb522dd61a4c2c4ec5 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 16 Mar 2020 06:39:42 -0300 Subject: [PATCH] enable/disable instead of set --- lbry/extras/daemon/daemon.py | 29 ++++++++++++++----- .../integration/other/test_other_commands.py | 4 +-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index c63ce39ab..014a69194 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -4537,23 +4537,36 @@ class Daemon(metaclass=JSONRPCServerType): Controls and queries tracemalloc memory tracing tools for troubleshooting. """ - def jsonrpc_tracemalloc_set(self, enable: bool): # pylint: disable=no-self-use + def jsonrpc_tracemalloc_enable(self): # pylint: disable=no-self-use """ - Enable/disable tracemalloc memory tracing + Enable tracemalloc memory tracing Usage: - jsonrpc_tracemalloc_set ( | --enable=) + jsonrpc_tracemalloc_enable Options: - --enable= : (bool) True enables, False disables + None Returns: (bool) is it tracing? """ - if enable: - tracemalloc.start() - else: - tracemalloc.stop() + tracemalloc.start() + return tracemalloc.is_tracing() + + def jsonrpc_tracemalloc_disable(self): # pylint: disable=no-self-use + """ + Disable tracemalloc memory tracing + + Usage: + jsonrpc_tracemalloc_disable + + Options: + None + + Returns: + (bool) is it tracing? + """ + tracemalloc.stop() return tracemalloc.is_tracing() def jsonrpc_tracemalloc_top(self, items: int = 10): # pylint: disable=no-self-use diff --git a/tests/integration/other/test_other_commands.py b/tests/integration/other/test_other_commands.py index 5d1c74048..1ec10c4ba 100644 --- a/tests/integration/other/test_other_commands.py +++ b/tests/integration/other/test_other_commands.py @@ -42,8 +42,8 @@ class SettingsManagement(CommandTestCase): class TroubleshootingCommands(CommandTestCase): async def test_tracemalloc_commands(self): - self.assertFalse(self.daemon.jsonrpc_tracemalloc_set(False)) - self.assertTrue(self.daemon.jsonrpc_tracemalloc_set(True)) + self.assertFalse(self.daemon.jsonrpc_tracemalloc_disable()) + self.assertTrue(self.daemon.jsonrpc_tracemalloc_enable()) class WeirdObject(): pass