From 6f5193407c2eac18f2dcb69af6d38ffb1ab47f23 Mon Sep 17 00:00:00 2001 From: Jefferson Dantas Date: Sun, 29 Dec 2024 13:49:23 -0300 Subject: [PATCH] fix: Corrige problema com ping 999+ aumentando prioridade do processo --- requirements.txt | Bin 1234 -> 1264 bytes server/main.py | 6 ++++++ server/src/helpers.py | 15 +++++++++++++++ server/src/server.py | 9 --------- 4 files changed, 21 insertions(+), 9 deletions(-) delete mode 100644 server/src/server.py diff --git a/requirements.txt b/requirements.txt index 566fe0fa8ee67dbdd666c5685e678a138f610d5a..548f96a5ace3f9aa2d22d423a4e0e4d62089b6e7 100644 GIT binary patch delta 34 ocmcb_`GIpo3zJ|mLn%WELncEGgDnu6G3ZTR$fUS=29p&N0Iwqn3jhEB delta 12 Tcmeysd5LpF3)ALBOnyuNBnJet diff --git a/server/main.py b/server/main.py index 15ffc18..5d9d1a5 100644 --- a/server/main.py +++ b/server/main.py @@ -11,6 +11,12 @@ checkModules() +from src.helpers import setProcessPriority + +# Define a prioridade do processo do Python para alta +setProcessPriority() + + from src.http import startHTTPServer from src.websocket import startWebSocketServer diff --git a/server/src/helpers.py b/server/src/helpers.py index 38500f3..343fd02 100644 --- a/server/src/helpers.py +++ b/server/src/helpers.py @@ -182,3 +182,18 @@ def getVersion(): return content["version"] except: return "0.0.0" + + +# Define a prioridade do processo do Python para alta +def setProcessPriority(): + try: + import psutil + + proc = psutil.Process(os.getpid()) + + if os.name == "nt": + proc.nice(psutil.HIGH_PRIORITY_CLASS) + else: + proc.nice(-10) + except: + pass diff --git a/server/src/server.py b/server/src/server.py deleted file mode 100644 index fcb4756..0000000 --- a/server/src/server.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from colorama import init as coloramaInit -import os - - -# Inicializa o colorama -coloramaInit(autoreset=True)