Added more debugging

This commit is contained in:
root
2023-08-14 14:13:09 +02:00
parent c05d58907c
commit 219819738d
5 changed files with 28 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ import helpers
import walladb
import constants
import account_checker
import time
from worker import Worker
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, ForceReply
@@ -437,24 +438,37 @@ async def list_threads(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
else:
await update.message.reply_markdown_v2(helpers.telegram_escape_characters(f"{threads_string}"))
def count_threads():
time.sleep(10)
while True:
logging.info(f"=== There are: {threading.active_count()} threads. ===")
time.sleep(60)
def main()->None:
global SEARCH_THREADS_LIST
walladb.setup_db()
products = walladb.get_all_products()
"""Start the bot."""
# Create the Application and pass it your bot's token.
application = Application.builder().get_updates_http_version('1.1').http_version('1.1').token(constants.TELEGRAM_TOKEN).build()
logging.info(f"Loading {len(products)} products...")
count = 0
for product in products:
if helpers.is_valid_request(product):
count = count + 1
logging.info(product)
p = threading.Thread(target=Worker.run, args=(product, ))
p.start()
SEARCH_THREADS_LIST.append((product, p))
logging.info(f"{count} products finally loaded")
p = threading.Thread(target=account_checker.account_checker, args=(3600, ))
p.start()
"""Start the bot."""
# Create the Application and pass it your bot's token.
application = Application.builder().get_updates_http_version('1.1').http_version('1.1').token(constants.TELEGRAM_TOKEN).build()
p = threading.Thread(target=count_threads)
p.start()
# on different commands - answer in Telegram
application.add_handler(CommandHandler("help", help_command))