Код: Выделить всё
# save as test.py
import subprocess as sp
import time
script = '''#!/bin/bash
nohup sleep 10 &
'''
with open('test.sh', 'w') as f:
f.write(script)
start_ts = time.time()
cp = sp.run('bash test.sh', shell=True, capture_output=True)
print(f'Elapsed time: {time.time() - start_ts:.2f}s')
я ожидаю, что он должен немедленно остановиться,
но вместо этого он ожидает 10 секунд .
Почему? Как я могу это исправить?
Подробнее здесь: https://stackoverflow.com/questions/793 ... ash-script