Reputation: 514
I use subprocess.popen
command to scan a frequency.
My programm receives data, but, I am having difficulties to detect 'the end of a message'.
So, I am looking for the code how to check if the .poll()
command is polling, but not receiving data.
As far as I have found with google, line should be '' when no data received, and just once, the program responded by printing several empty lines. Unfortunately, this was only once, but, that could be what I am looking for. Meaning, 2 or 3 empty lines will probably also indicate there is no data to be received.
multimon_ng = subprocess.Popen("rtl_fm -f 169.65M -M fm -s 22050 -p 43 -g 30 | multimon-ng -a FLEX -t raw -",
stdout = subprocess.PIPE,
stderr = open('error.txt', 'a'),
shell = True)
while True:
multimon_ng.poll()
line = multimon_ng.stdout.readline()
print(line)
How to check if subprocess is polling?
Upvotes: 0
Views: 285
Reputation: 1852
If the process is still running, poll()
will return None
. Otherwise it will return the exit code. (From the docs)
However, I'm not sure that will help you here:
wait()
instead of using poll()
.stdout.readline()
in a loop, and detect and handle that signal without exiting that loop.Upvotes: 1