33"""
44# flake8: noqa: E402
55import logging
6- import threading
7- import sys
86from helpermodules import logger
97from helpermodules .utils import run_command , thread_handler
10- from helpermodules .utils ._exit_after import TimeoutException
8+ import threading
9+ import sys
1110
1211# als erstes logging initialisieren, damit auch ImportError geloggt werden
1312logger .setup_logging ()
@@ -46,9 +45,9 @@ def __init__(self):
4645 def handler10Sec (self ):
4746 """ führt den Algorithmus durch.
4847 """
49- @ exit_after ( data . data . general_data . data . control_interval )
50- def handler_with_control_interval ():
51- try :
48+ try :
49+ @ exit_after ( data . data . general_data . data . control_interval )
50+ def handler_with_control_interval () :
5251 if (data .data .general_data .data .control_interval / 10 ) == self .interval_counter :
5352 data .data .copy_data ()
5453 loadvars_ .get_values ()
@@ -70,10 +69,6 @@ def handler_with_control_interval():
7069 self .interval_counter = 1
7170 else :
7271 self .interval_counter = self .interval_counter + 1
73- except Exception :
74- log .exception ("Fehler im Main-Modul 10s-Handler" )
75-
76- try :
7772 log .info ("# ***Start*** " )
7873 log .debug (run_command .run_shell_command ("top -b -n 1 | head -n 20" ))
7974 log .debug (f'Drosselung: { run_command .run_shell_command ("if which vcgencmd >/dev/null; then vcgencmd get_throttled; else echo not found; fi" )} ' )
@@ -91,7 +86,7 @@ def handler_with_control_interval():
9186 logging .debug (line .strip ())
9287 Pub ().pub ("openWB/set/system/time" , timecheck .create_timestamp ())
9388 handler_with_control_interval ()
94- except TimeoutException :
89+ except KeyboardInterrupt :
9590 log .critical ("Ausführung durch exit_after gestoppt: " + traceback .format_exc ())
9691 except Exception :
9792 log .exception ("Fehler im Main-Modul" )
@@ -109,7 +104,7 @@ def handler5MinAlgorithm(self):
109104 data .data .general_data .grid_protection ()
110105 data .data .optional_data .ocpp_transfer_meter_values ()
111106 data .data .counter_all_data .validate_hierarchy ()
112- except TimeoutException :
107+ except KeyboardInterrupt :
113108 log .critical ("Ausführung durch exit_after gestoppt: " + traceback .format_exc ())
114109 except Exception :
115110 log .exception ("Fehler im Main-Modul" )
@@ -144,7 +139,7 @@ def handler5Min(self):
144139 general_internal_chargepoint_handler .internal_chargepoint_handler .heartbeat = False
145140 with ChangedValuesContext (loadvars_ .event_module_update_completed ):
146141 sub .system_data ["system" ].update_ip_address ()
147- except TimeoutException :
142+ except KeyboardInterrupt :
148143 log .critical ("Ausführung durch exit_after gestoppt: " + traceback .format_exc ())
149144 except Exception :
150145 log .exception ("Fehler im Main-Modul" )
@@ -156,7 +151,7 @@ def handler_midnight(self):
156151 thread_errors_path = Path (Path (__file__ ).resolve ().parents [1 ]/ "ramdisk" / "thread_errors.log" )
157152 with thread_errors_path .open ("w" ) as f :
158153 f .write ("" )
159- except TimeoutException :
154+ except KeyboardInterrupt :
160155 log .critical ("Ausführung durch exit_after gestoppt: " + traceback .format_exc ())
161156 except Exception :
162157 log .exception ("Fehler im Main-Modul" )
@@ -165,7 +160,7 @@ def handler_midnight(self):
165160 def handler_random_nightly (self ):
166161 try :
167162 data .data .system_data ["system" ].thread_backup_and_send_to_cloud ()
168- except TimeoutException :
163+ except KeyboardInterrupt :
169164 log .critical ("Ausführung durch exit_after gestoppt: " + traceback .format_exc ())
170165 except Exception :
171166 log .exception ("Fehler im Main-Modul" )
@@ -177,7 +172,7 @@ def handler_hour(self):
177172 for cp in data .data .cp_data .values ():
178173 calculate_charge_cost (cp )
179174 data .data .optional_data .et_get_prices ()
180- except TimeoutException :
175+ except KeyboardInterrupt :
181176 log .critical ("Ausführung durch exit_after gestoppt: " + traceback .format_exc ())
182177 except Exception :
183178 log .exception ("Fehler im Main-Modul" )
0 commit comments