python 3.x – Stop a subprocess when a specific string is found in the logs

This is a question about subprocesses.

I'm working on using this asynchronous script for some of my work:

The functionality of the script is not as important as the way I want to use this script.

Since it is asynchronous, I want to run it in a subprocess with different values. For each subprocess, I want to wait for a certain amount of time before looking for a string in the script logs. If I find the string I am looking for, I leave the subprocess for this passed parameter and a new parameter, repeating the process.

Of a high level, it is the subprocess script that I try.

import subprocess
enode = & # 39; enode: //ecd3f3de6fc1a69fdbb459ccfeedb9ae4b@ 30303 & # 39;

command = [
proc = subprocess.Popen (command)
outs, errs = proc.communicate (wait time = 15)
except TimeoutExpired:
proc.kill ()
outs, errs = proc.communicate ()
printing (outs)
print (errs)

This code does not work and never leaves the script. How can I use a subprocess with an asynchronous script to be able to stop when I look for a value in the subprocess logs and the value I am looking for is there?

The chain in the newspapers I am looking for is: CAO range control validation failed that I would use as a trigger to stop the script.