Disabled tracemalloc

This commit is contained in:
Joan
2023-08-16 11:56:44 +02:00
parent 565ca4b473
commit e3fdea98ad
2 changed files with 0 additions and 32 deletions

View File

@@ -5,7 +5,6 @@ import walladb
import constants import constants
import account_checker import account_checker
import time import time
import tracemalloc
from worker import Worker from worker import Worker
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, ForceReply from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, ForceReply
@@ -440,26 +439,10 @@ async def list_threads(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
await update.message.reply_markdown_v2(helpers.telegram_escape_characters(f"{threads_string}")) await update.message.reply_markdown_v2(helpers.telegram_escape_characters(f"{threads_string}"))
def count_threads(): def count_threads():
tracemalloc.start()
time.sleep(10) time.sleep(10)
while True: while True:
snapshot1 = tracemalloc.take_snapshot()
logging.info(f"=== There are: {threading.active_count()} threads. ===") logging.info(f"=== There are: {threading.active_count()} threads. ===")
time.sleep(60) time.sleep(60)
snapshot2 = tracemalloc.take_snapshot()
top_stats = snapshot2.compare_to(snapshot1, 'lineno')
logging.info("[ Top 10 differences ]")
for stat in top_stats[:10]:
logging.info(stat)
top_stats = snapshot2.statistics('lineno')
logging.info("[ Top 10 ]")
for stat in top_stats[:10]:
logging.info(stat)
def main()->None: def main()->None:
global SEARCH_THREADS_LIST global SEARCH_THREADS_LIST

View File

@@ -4,7 +4,6 @@ import logging
import helpers import helpers
import walladb import walladb
import constants import constants
import tracemalloc
# Enable logging # Enable logging
logging.basicConfig( logging.basicConfig(
@@ -98,7 +97,6 @@ class Worker:
helpers.random_wait() # Random wait to make requests separated in time in order to prevent API rate limit helpers.random_wait() # Random wait to make requests separated in time in order to prevent API rate limit
exec_times = [] exec_times = []
while True: while True:
snapshot1 = tracemalloc.take_snapshot()
#logging.info(f"List for {product['product_name']} length is: {len(list)}") #logging.info(f"List for {product['product_name']} length is: {len(list)}")
if not helpers.is_valid_request(product) or self._stop == True: if not helpers.is_valid_request(product) or self._stop == True:
logging.info(f"{product['product_name']} not valid anymore, exiting worker") logging.info(f"{product['product_name']} not valid anymore, exiting worker")
@@ -139,18 +137,6 @@ class Worker:
time.sleep(constants.SLEEP_TIME) time.sleep(constants.SLEEP_TIME)
exec_times.append(time.time() - start_time) exec_times.append(time.time() - start_time)
logging.info(f"\'{product['product_name']}\' for {walladb.get_user(product['telegram_user_id'])} ({product['telegram_user_id']}) node-> last: {exec_times[-1]:.2f} max: {self.get_max_time(exec_times):.2f} avg: {self.get_average_time(exec_times):.2f}") logging.info(f"\'{product['product_name']}\' for {walladb.get_user(product['telegram_user_id'])} ({product['telegram_user_id']}) node-> last: {exec_times[-1]:.2f} max: {self.get_max_time(exec_times):.2f} avg: {self.get_average_time(exec_times):.2f}")
snapshot2 = tracemalloc.take_snapshot()
top_stats = snapshot2.compare_to(snapshot1, 'lineno')
logging.info(f"[ Top 10 differences {product['product_name']} ]")
for stat in top_stats[:10]:
logging.info(stat)
top_stats = snapshot2.statistics('lineno')
logging.info(f"[ Top 10 {product['product_name']} ]")
for stat in top_stats[:10]:
logging.info(stat)
def has_excluded_words(self, title, description, excluded_words): def has_excluded_words(self, title, description, excluded_words):
if len(excluded_words) > 0: if len(excluded_words) > 0:
@@ -187,7 +173,6 @@ class Worker:
self._stop = True self._stop = True
def run(product): def run(product):
tracemalloc.start()
worker = Worker() worker = Worker()
try: try:
list = worker.first_run(product) list = worker.first_run(product)