diff --git a/app/views.py b/app/views.py index dfe7768..308224b 100644 --- a/app/views.py +++ b/app/views.py @@ -34,12 +34,17 @@ def run_telnet_command(powerbar, command): try: tn = get_telnet_connection(powerbar) tn.write(f"{command}\r\n".encode('ascii')) + time.sleep(0.2) + tn.write(f"{command}\r\n".encode('ascii')) return except Exception as e: print(f"Telnet error: {e}") - active_telnet_connections.pop(powerbar) + if powerbar in active_telnet_connections: + active_telnet_connections.pop(powerbar) tn = get_telnet_connection(powerbar) tn.write(f"{command}\r\n".encode('ascii')) + time.sleep(0.2) + tn.write(f"{command}\r\n".encode('ascii')) return