@@ -166,6 +166,7 @@ def main(args=None):
166166 service_call_timeout = args .service_call_timeout
167167 switch_timeout = args .switch_timeout
168168 strictness = SwitchController .Request .STRICT
169+ unload_controllers_upon_exit = False
169170
170171 if param_files :
171172 for param_file in param_files :
@@ -342,15 +343,15 @@ def main(args=None):
342343 + f"Configured and activated all the parsed controllers list : { controller_names } !"
343344 + bcolors .ENDC
344345 )
345-
346- if not args . unload_on_kill :
346+ unload_controllers_upon_exit = args . unload_on_kill
347+ if not unload_controllers_upon_exit :
347348 return 0
348349
349- try :
350- node . get_logger (). info ( "Waiting until interrupt to unload controllers" )
351- while True :
352- time . sleep ( 1 )
353- except KeyboardInterrupt :
350+ node . get_logger (). info ( "Waiting until interrupt to unload controllers" )
351+ while True :
352+ time . sleep ( 1 )
353+ except KeyboardInterrupt :
354+ if unload_controllers_upon_exit :
354355 node .get_logger ().info ("KeyboardInterrupt successfully captured!" )
355356 if not args .inactive :
356357 node .get_logger ().info ("Deactivating and unloading controllers..." )
@@ -396,10 +397,9 @@ def main(args=None):
396397 node .get_logger ().info (f"Successfully unloaded controllers : { controller_names } " )
397398 else :
398399 return 1
399- return 0
400- except KeyboardInterrupt :
401- node .get_logger ().info ("KeyboardInterrupt received! Exiting...." )
402- pass
400+ else :
401+ node .get_logger ().info ("KeyboardInterrupt received! Exiting...." )
402+ pass
403403 except ServiceNotFoundError as err :
404404 node .get_logger ().fatal (str (err ))
405405 return 1
0 commit comments