Compare commits

...

1 commit

Author SHA1 Message Date
Victor Shyba
5718be1c61 log top memory usage on status if tracemalloc enabled 2019-09-16 15:00:35 -03:00

View file

@ -9,6 +9,7 @@ import base58
import random
import ecdsa
import hashlib
import tracemalloc
from urllib.parse import urlencode, quote
from typing import Callable, Optional, List
from binascii import hexlify, unhexlify
@ -145,6 +146,14 @@ DHT_HAS_CONTACTS = "dht_has_contacts"
WALLET_IS_UNLOCKED = "wallet_is_unlocked"
def debug_log_tracemalloc():
snapshot = tracemalloc.take_snapshot()
top_stats = snapshot.statistics('lineno')
log.debug("[ Top 10 memory usage ]")
for stat in top_stats[:10]:
log.debug(stat)
class DHTHasContacts(RequiredCondition):
name = DHT_HAS_CONTACTS
component = DHT_COMPONENT
@ -795,6 +804,8 @@ class Daemon(metaclass=JSONRPCServerType):
}
}
"""
if tracemalloc.is_tracing():
debug_log_tracemalloc()
connection_code = await self.get_connection_status()