Skip to content

Commit

Permalink
add some debug symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Dec 30, 2023
1 parent b82e48c commit 6c37e82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ mnemonic==0.20
qrcode==7.4.2
blinker==1.7.0
flask===3.0.0
objgraph==3.6.0
pympler==1.0.1
12 changes: 12 additions & 0 deletions ytdlbot/ytdl_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
from io import BytesIO
from typing import Any

import objgraph
import pyrogram.errors
import qrcode
import yt_dlp
from apscheduler.schedulers.background import BackgroundScheduler
from pympler import tracker
from pyrogram import Client, enums, filters, types
from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant
from pyrogram.raw import functions
Expand Down Expand Up @@ -569,8 +571,17 @@ def trx_notify(_, **kwargs):
app.send_message(user_id, text)


def track_memory():
print("\n\nobjgraph result:")
objgraph.show_growth()
objgraph.show_most_common_types()
print("\n\npympler result:")
tr.print_diff()


if __name__ == "__main__":
MySQL()
tr = tracker.SummaryTracker()
TRX_SIGNAL.connect(trx_notify)
scheduler = BackgroundScheduler(timezone="Europe/London", job_defaults={"max_instances": 6})
scheduler.add_job(auto_restart, "interval", seconds=600)
Expand All @@ -579,6 +590,7 @@ def trx_notify(_, **kwargs):
scheduler.add_job(Redis().reset_today, "cron", hour=0, minute=0)
scheduler.add_job(InfluxDB().collect_data, "interval", seconds=120)
scheduler.add_job(TronTrx().check_payment, "interval", seconds=60, max_instances=1)
scheduler.add_job(track_memory, "interval", seconds=120, max_instances=1)
# default quota allocation of 10,000 units per day
scheduler.add_job(periodic_sub_check, "interval", seconds=3600)
scheduler.start()
Expand Down

0 comments on commit 6c37e82

Please sign in to comment.