Add timeout to con_get_output

This commit is contained in:
Rudra Saraswat 2023-04-21 19:13:54 +05:30
parent 60acc7ba05
commit 38e93d1218

View file

@ -212,8 +212,12 @@ def create_container_sessions(type='xsessions'):
f'{session_dir}/blend-{c};{i}'), 0o775) f'{session_dir}/blend-{c};{i}'), 0o775)
def con_get_output(name, cmd): return subprocess.run(['sudo', '-u', user, 'podman', 'exec', '--user', getpass.getuser(), '-it', name, 'bash', '-c', cmd], def con_get_output(name, cmd):
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode('UTF-8').strip() try:
return subprocess.run(['sudo', '-u', user, 'podman', 'exec', '--user', getpass.getuser(), '-it', name, 'bash', '-c', cmd],
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, timeout=5).stdout.decode('UTF-8').strip()
except subprocess.TimeoutExpired:
return ''
user = getpass.getuser() user = getpass.getuser()