add delay in connection_handler to ensure resources are freed before process restart
This commit is contained in:
@@ -14,6 +14,7 @@ import asyncio
|
||||
import sys
|
||||
import signal
|
||||
import uvloop
|
||||
import time
|
||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||
|
||||
from pyrogram import Client
|
||||
@@ -79,6 +80,11 @@ class TelegramClient:
|
||||
if loop.is_running():
|
||||
loop.create_task(self.stop())
|
||||
|
||||
# Добавляем задержку, чтобы предыдущий процесс успел завершиться
|
||||
# и освободить порт и другие ресурсы
|
||||
logger.info("connection_handler: waiting for resources to be freed before restart")
|
||||
time.sleep(3)
|
||||
|
||||
# Use os.execv to restart the process with the same arguments
|
||||
os.execv(sys.executable, [sys.executable] + sys.argv)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user