Skip to content

Commit

Permalink
use session
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Apr 15, 2023
1 parent 4c337fa commit 07cbf8f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,7 @@ reinforcement/*
/ytdlbot/session/ytdl.session-journal
/ytdlbot/unknown_errors.txt
/ytdlbot/ytdl.session-journal
/ytdlbot/ytdl-main.session-journal
/ytdlbot/ytdl-main.session
/ytdlbot/ytdl-celery.session-journal
/ytdlbot/ytdl-celery.session
2 changes: 1 addition & 1 deletion ytdlbot/client_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from config import APP_HASH, APP_ID, PYRO_WORKERS, TOKEN, IPv6


def create_app(session="ytdl", workers=PYRO_WORKERS):
def create_app(session, workers=PYRO_WORKERS):
_app = Client(
session,
APP_ID,
Expand Down
8 changes: 5 additions & 3 deletions ytdlbot/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
BROKER,
ENABLE_CELERY,
ENABLE_QUEUE,
RATE_LIMIT,
ENABLE_VIP,
OWNER,
RATE_LIMIT,
TG_MAX_SIZE,
WORKERS,
)
Expand All @@ -68,7 +68,9 @@
app = Celery("tasks", broker=BROKER)
redis = Redis()
channel = Channel()
celery_client = create_app(":memory:")

session = "ytdl-celery"
celery_client = create_app(session)


def get_messages(chat_id, message_id):
Expand Down Expand Up @@ -481,7 +483,7 @@ def purge_tasks():


if __name__ == "__main__":
celery_client.start()
# celery_client.start()
print("Bootstrapping Celery worker now.....")
time.sleep(5)
threading.Thread(target=run_celery, daemon=True).start()
Expand Down
3 changes: 2 additions & 1 deletion ytdlbot/ytdl_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
customize_logger(["pyrogram.client", "pyrogram.session.session", "pyrogram.connection.connection"])
logging.getLogger("apscheduler.executors.default").propagate = False

app = create_app(":memory:")
session = "ytdl-main"
app = create_app(session)

logging.info("Authorized users are %s", AUTHORIZED_USER)
redis = Redis()
Expand Down

0 comments on commit 07cbf8f

Please sign in to comment.