This is a question about subprocesses.
I'm working on using this asynchronous script for some of my work: https://github.com/ethereum/trinity/blob/master/scripts/peer.py
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: //email@example.com: 30303 & # 39; command = [ 'python', '-m', 'scripts.peer', '-mainnet', '-enode', enode ] proc = subprocess.Popen (command) try: 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.