Did you try the wait method for a subprocess object?
like this example:
from subprocess import Popen, PIPE
#call sleep with arg = 5 seconds
l = Popen(['sleep','5'])
#wait for 4 seconds
l.wait(4)
If you run this, you will have an error after 4 seconds, but if you change the argument for the wait function for 6 for example, it wont return any error.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…