Skip to content

Commit 1366f7d

Browse files
committed
Fix for hanging requests, Remove PID File
- Removed PID file generation, uneeded use matching process to plane-notify name - Add timeout to requests for ADSBX, previously hanging. - Fix exception for Discord
1 parent 405cc54 commit 1366f7d

File tree

3 files changed

+3
-17
lines changed

3 files changed

+3
-17
lines changed

__main__.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66
if platform.system() == "Windows":
77
from colorama import init
88
init(convert=True)
9-
elif platform.system() == "Linux":
10-
pid_file_path = "/home/plane-notify/pid.pid"
11-
def write_pid_file(filepath):
12-
import os
13-
pid = str(os.getpid())
14-
f = open(filepath, 'w')
15-
f.write(pid)
16-
f.close()
17-
write_pid_file(pid_file_path)
18-
print("Made PIDFile")
199
from planeClass import Plane
2010
from datetime import datetime
2111
import pytz
@@ -63,7 +53,6 @@ def service_exit(signum, frame):
6353
if main_config.getboolean('DISCORD', 'ENABLE'):
6454
from defDiscord import sendDis
6555
sendDis("Service Stop", main_config)
66-
os.remove(pid_file_path)
6756
raise SystemExit("Service Stop")
6857
signal.signal(signal.SIGTERM, service_exit)
6958
if os.path.isfile("lookup_route.py"):
@@ -223,7 +212,4 @@ def service_exit(signum, frame):
223212
logging.error(str(traceback.format_exc()))
224213
from defDiscord import sendDis
225214
sendDis(str("Error Exiting: " + str(e) + "Failed on " + key), main_config, "crash_latest.log")
226-
raise e
227-
finally:
228-
if platform.system() == "Linux":
229-
os.remove(pid_file_path)
215+
raise e

defADSBX.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def pull(url, headers):
1414
try:
15-
response = requests.get(url, headers = headers)
15+
response = requests.get(url, headers = headers, timeout=30)
1616
print ("HTTP Status Code:", response.status_code)
1717
response.raise_for_status()
1818
except (requests.HTTPError, ConnectionError, requests.Timeout, urllib3.exceptions.ConnectionError) as error_message:

defDiscord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ def sendDis(message, config, file_name = None, role_id = None):
99
webhook.add_file(file=f.read(), filename=file_name)
1010
try:
1111
webhook.execute()
12-
except requests.Exceptions:
12+
except requests.exceptions.RequestException:
1313
pass

0 commit comments

Comments
 (0)