diff --git a/bridge_master.py b/bridge_master.py index b30cc5a..a2edc8e 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -302,7 +302,7 @@ def reset_static_tg(tg,ts,_tmout,system): def reset_all_reflector_system(_tmout,system): for system in CONFIG['SYSTEMS']: - for bridge in BRIDGES: + for bridge in list(BRIDGES): if bridge[0:1] == '#': for bridgesystem in BRIDGES[bridge]: bridgetemp = deque() @@ -337,6 +337,8 @@ def remove_bridge_system(system): _bridgestemp = {} _bridgetemp = {} for _bridge in list(BRIDGES): + if _bridge not in BRIDGES: + continue for _bridgesystem in BRIDGES[_bridge]: if _bridgesystem['SYSTEM'] != system: if _bridge not in _bridgestemp: @@ -352,6 +354,8 @@ def remove_bridge_system(system): def deactivate_all_dynamic_bridges(system_name): """Desactiva todos los bridges dinámicos (no estáticos, no reflectores) de un sistema.""" for _bridge in list(BRIDGES): + if _bridge not in BRIDGES: + continue if _bridge[0:1] == '#': # Saltar reflectores continue for _sys_entry in BRIDGES[_bridge]: @@ -373,6 +377,8 @@ def rule_timer_loop(): _debug_msgs = [] for _bridge in list(BRIDGES): + if _bridge not in BRIDGES: + continue _bridge_used = False ### MODIFIED: Detect special TGIDs (9990-9999) to exclude them from infinite timer logic @@ -471,6 +477,8 @@ def statTrimmer(): logger.debug('(ROUTER) STAT trimmer loop started') _remove_bridges = deque() for _bridge in list(BRIDGES): + if _bridge not in BRIDGES: + continue _bridge_stat = False _in_use = False for _system in BRIDGES[_bridge]: @@ -531,6 +539,8 @@ def bridgeDebug(): #_setbridge = str(times[bridgetmout]) if CONFIG['SYSTEMS'][system]['MODE'] == 'MASTER': for _bridge in set(times.values()): + if _bridge not in BRIDGES: + continue logger.warning('(BRIDGEDEBUG) deactivating system: %s for bridge: %s',system,_bridge) bridgetemp = deque() for bridgesystem in BRIDGES[_bridge]: @@ -1810,7 +1820,9 @@ def options_config(): if int(_options['DEFAULT_UA_TIMER']) != CONFIG['SYSTEMS'][_system]['DEFAULT_UA_TIMER']: logger.debug('(OPTIONS) %s Updating DEFAULT_UA_TIMER for existing bridges.',_system) remove_bridge_system(_system) - for _bridge in BRIDGES: + for _bridge in list(BRIDGES): + if _bridge not in BRIDGES: + continue ts1 = False ts2 = False for i,e in enumerate(BRIDGES[_bridge]): @@ -2482,7 +2494,9 @@ class routerOBP(OPENBRIDGE): make_stat_bridge(_dst_id) _sysIgnore = deque() - for _bridge in BRIDGES: + for _bridge in list(BRIDGES): + if _bridge not in BRIDGES: + continue for _system in BRIDGES[_bridge]: if _system['SYSTEM'] == self._system and _system['TGID'] == _dst_id and _system['TS'] == _slot and _system['ACTIVE'] == True: @@ -3400,7 +3414,9 @@ class routerHBP(HBSYSTEM): # Now, run the general routing loop for all other bridges to handle cross-connections. # We skip the one we just processed to avoid duplicate work. - for _bridge in BRIDGES: + for _bridge in list(BRIDGES): + if _bridge not in BRIDGES: + continue if _bridge == _current_bridge_key: continue for _system in BRIDGES[_bridge]: @@ -3429,7 +3445,9 @@ class routerHBP(HBSYSTEM): # # Iterate the rules dictionary - for _bridge in BRIDGES: + for _bridge in list(BRIDGES): + if _bridge not in BRIDGES: + continue if (_bridge[0:1] == '#') and (_int_dst_id != 9): continue for _system in BRIDGES[_bridge]: