Implement proper cleanup mechanism
This commit is contained in:
parent
b41f2b8f7f
commit
e4c4f1b41f
|
@ -28,12 +28,33 @@ Factory.noisy = False
|
||||||
|
|
||||||
# TODO: extend this with more
|
# TODO: extend this with more
|
||||||
def cleanup(sig, frame):
|
def cleanup(sig, frame):
|
||||||
|
to_cleanup = []
|
||||||
|
if hasattr(init_map["money"], "lc_es_checks"):
|
||||||
|
to_cleanup.append(init_map["money"].lc_es_checks.stop)
|
||||||
|
if hasattr(init_map["sources"].agora, "lc_dash"):
|
||||||
|
to_cleanup.append(init_map["sources"].agora.lc_dash.stop)
|
||||||
|
if hasattr(init_map["sources"].agora, "lc_cheat"):
|
||||||
|
to_cleanup.append(init_map["sources"].agora.lc_cheat.stop)
|
||||||
|
if hasattr(init_map["sources"].lbtc, "lc_dash"):
|
||||||
|
to_cleanup.append(init_map["sources"].lbtc.lc_dash.stop)
|
||||||
|
if hasattr(init_map["sources"].lbtc, "lc_cheat"):
|
||||||
|
to_cleanup.append(init_map["sources"].lbtc.lc_cheat.stop)
|
||||||
|
if hasattr(init_map["sinks"], "truelayer"):
|
||||||
|
if hasattr(init_map["sinks"].truelayer, "lc"):
|
||||||
|
to_cleanup.append(init_map["sinks"].truelayer.lc.stop)
|
||||||
|
if hasattr(init_map["sinks"].truelayer, "lc_tx"):
|
||||||
|
to_cleanup.append(init_map["sinks"].truelayer.lc_tx.stop)
|
||||||
|
if hasattr(init_map["sinks"], "nordigen"):
|
||||||
|
if hasattr(init_map["sinks"].nordigen, "lc"):
|
||||||
|
to_cleanup.append(init_map["sinks"].nordigen.lc.stop)
|
||||||
|
if hasattr(init_map["sinks"].nordigen, "lc_tx"):
|
||||||
|
to_cleanup.append(init_map["sinks"].nordigen.lc_tx.stop)
|
||||||
if init_map:
|
if init_map:
|
||||||
|
for func in to_cleanup:
|
||||||
try:
|
try:
|
||||||
init_map["tx"].lc_es_checks.stop()
|
func()
|
||||||
init_map["agora"].lc_dash.stop()
|
|
||||||
init_map["agora"].lc_cheat.stop()
|
|
||||||
except: # noqa
|
except: # noqa
|
||||||
|
print(f"Exception when stopping {func}")
|
||||||
pass # noqa
|
pass # noqa
|
||||||
reactor.stop()
|
reactor.stop()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue