forked from LBRYCommunity/lbry-sdk
log top memory usage on status if tracemalloc enabled
This commit is contained in:
parent
5c151a3a09
commit
5718be1c61
1 changed files with 11 additions and 0 deletions
|
@ -9,6 +9,7 @@ import base58
|
||||||
import random
|
import random
|
||||||
import ecdsa
|
import ecdsa
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import tracemalloc
|
||||||
from urllib.parse import urlencode, quote
|
from urllib.parse import urlencode, quote
|
||||||
from typing import Callable, Optional, List
|
from typing import Callable, Optional, List
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
|
@ -145,6 +146,14 @@ DHT_HAS_CONTACTS = "dht_has_contacts"
|
||||||
WALLET_IS_UNLOCKED = "wallet_is_unlocked"
|
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):
|
class DHTHasContacts(RequiredCondition):
|
||||||
name = DHT_HAS_CONTACTS
|
name = DHT_HAS_CONTACTS
|
||||||
component = DHT_COMPONENT
|
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()
|
connection_code = await self.get_connection_status()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue