@@ -159,6 +159,7 @@ def main(args=None):
159159 service_call_timeout = args .service_call_timeout
160160 switch_timeout = args .switch_timeout
161161 strictness = SwitchController .Request .STRICT
162+ unload_controllers_upon_exit = False
162163
163164 if param_files :
164165 for param_file in param_files :
@@ -321,15 +322,15 @@ def main(args=None):
321322 + f"Configured and activated all the parsed controllers list : { controller_names } !"
322323 + bcolors .ENDC
323324 )
324-
325- if not args . unload_on_kill :
325+ unload_controllers_upon_exit = args . unload_on_kill
326+ if not unload_controllers_upon_exit :
326327 return 0
327328
328- try :
329- node . get_logger (). info ( "Waiting until interrupt to unload controllers" )
330- while True :
331- time . sleep ( 1 )
332- except KeyboardInterrupt :
329+ node . get_logger (). info ( "Waiting until interrupt to unload controllers" )
330+ while True :
331+ time . sleep ( 1 )
332+ except KeyboardInterrupt :
333+ if unload_controllers_upon_exit :
333334 node .get_logger ().info ("KeyboardInterrupt successfully captured!" )
334335 if not args .inactive :
335336 node .get_logger ().info ("Deactivating and unloading controllers..." )
@@ -375,10 +376,9 @@ def main(args=None):
375376 node .get_logger ().info (f"Successfully unloaded controllers : { controller_names } " )
376377 else :
377378 return 1
378- return 0
379- except KeyboardInterrupt :
380- node .get_logger ().info ("KeyboardInterrupt received! Exiting...." )
381- pass
379+ else :
380+ node .get_logger ().info ("KeyboardInterrupt received! Exiting...." )
381+ pass
382382 except ServiceNotFoundError as err :
383383 node .get_logger ().fatal (str (err ))
384384 return 1
0 commit comments