libkas: Do not sys.exit from a coroutine
That only creates exceptions and complaints if more routines are running or we are already in the exiting process. Rather leave the coroutine and catch the error on the waiting end. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
		
				
					committed by
					
						
						Daniel Wagner
					
				
			
			
				
	
			
			
			
						parent
						
							f0a18868c9
						
					
				
				
					commit
					adb4007482
				
			@@ -122,7 +122,6 @@ def run_cmd_async(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
 | 
				
			|||||||
        for line in logo.stderr:
 | 
					        for line in logo.stderr:
 | 
				
			||||||
            msg += line
 | 
					            msg += line
 | 
				
			||||||
        logging.error(msg)
 | 
					        logging.error(msg)
 | 
				
			||||||
        sys.exit(ret)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (ret, ''.join(logo.stdout))
 | 
					    return (ret, ''.join(logo.stdout))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -134,8 +133,11 @@ def run_cmd(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
 | 
				
			|||||||
    # pylint: disable=too-many-arguments
 | 
					    # pylint: disable=too-many-arguments
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    loop = asyncio.get_event_loop()
 | 
					    loop = asyncio.get_event_loop()
 | 
				
			||||||
    return loop.run_until_complete(
 | 
					    (ret, output) = loop.run_until_complete(
 | 
				
			||||||
        run_cmd_async(cmd, cwd, env, fail, shell, liveupdate))
 | 
					        run_cmd_async(cmd, cwd, env, fail, shell, liveupdate))
 | 
				
			||||||
 | 
					    if ret and fail:
 | 
				
			||||||
 | 
					        sys.exit(ret)
 | 
				
			||||||
 | 
					    return (ret, output)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def find_program(paths, name):
 | 
					def find_program(paths, name):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user