improved error handling

instead of having a component crashing, it will issue a warning with the error
This commit is contained in:
study-faraphel 2025-02-02 23:31:06 +01:00
parent e12073ede0
commit 9480339b89
5 changed files with 28 additions and 7 deletions

View file

@ -4,7 +4,6 @@ from datetime import datetime, timedelta
import numpy
import pause
import pydub
from numpy.f2py.auxfuncs import l_and
from pydub.utils import make_chunks
from source.behaviors.roles import base
@ -68,8 +67,6 @@ class MasterRole(base.BaseActiveRole):
if latency > self.latency:
self.latency = latency
print(self.latency)
# broadcast it in the network
audio_packet = AudioPacket(
# TODO(Faraphel): adjust time depending on the network average latency ?

View file

@ -1,5 +1,7 @@
import threading
import traceback
import typing
import warnings
from datetime import datetime
import numpy
@ -96,4 +98,8 @@ class AudioManager:
"""
while True:
self.handle()
try:
self.handle()
except Exception: # NOQA
warnings.warn(traceback.format_exc())

View file

@ -2,6 +2,8 @@ import hashlib
import json
import random
import tempfile
import traceback
import warnings
from pathlib import Path
import pyudev
@ -73,4 +75,8 @@ class DriveManager:
def loop(self) -> None:
while True:
self.handle()
try:
self.handle()
except Exception: # NOQA
warnings.warn(traceback.format_exc())

View file

@ -1,4 +1,6 @@
import time
import traceback
import warnings
from source import packets, structures
from source.managers import Manager
@ -24,7 +26,11 @@ class PeerManager:
def loop(self) -> None:
while True:
self.handle()
try:
self.handle()
except Exception: # NOQA
warnings.warn(traceback.format_exc())
# TODO(Faraphel): adjust sleep time ? as much seconds as there are peer to avoid flooding the network ?
time.sleep(1)

View file

@ -1,3 +1,6 @@
import traceback
import warnings
from source.behaviors import roles
from source.managers import Manager
@ -26,4 +29,7 @@ class RoleManager:
"""
while True:
self.handle()
try:
self.handle()
except Exception: # NOQA
warnings.warn(traceback.format_exc())