File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
openwisp_controller/connection Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,23 @@ def update_config(self, device_id):
6060 except NoWorkingDeviceConnectionError :
6161 return
6262 else :
63- logger .info (f"Updating { device } (pk: { device_id } )" )
63+ logger .info (f"Updating { device } (pk: { device_id } )" )
64+
65+ try :
6466 device_conn .update_config ()
67+ except Exception as e :
68+ logger .error (f"update_config failed for device { device_id } : { e } " )
69+ raise
70+ finally :
71+ # ensure connection is closed
72+ close_method = getattr (device_conn , "close" , None )
73+ if callable (close_method ):
74+ try :
75+ close_method ()
76+ try :
77+ device_conn .close ()
78+ except Exception as close_err :
79+ logger .warning (f"Error closing connection: { close_err } " )
6580
6681
6782# task timeout is SSH_COMMAND_TIMEOUT plus a 20% margin
You can’t perform that action at this time.
0 commit comments