Ping is producing many more lines than you're reading due to the 2 second timeout between reads. I'd move the os. Kill call into another thread, and use the main thread to read every line from proc.
Stdout : import sys, os import subprocess import threading import signal import time #Use ctrl-c and ctrl-break to terminate the script/ping def sigbreak(signum, frame): import sys if proc.poll() is None: print('Killing ping...') proc.kill() sys. Exit(0) signal. Signal(signal.
SIGBREAK, sigbreak) signal. Signal(signal. SIGINT, sigbreak) #executes in a separate thread def run(pid): while True: time.
Sleep(2) try: os. Kill(pid, signal. CTRL_BREAK_EVENT) except WindowsError: #quit the thread if ping is dead break cmd = r'c:\windows\system32\ping.
Exe', '127.0.0.1', '-l', '10000', '-t' flags = subprocess. CREATE_NEW_PROCESS_GROUP proc = subprocess. Popen(cmd, stdout=subprocess.
PIPE, creationflags=flags) threading. Thread(target=run, args=(proc. Pid,)).start() while True: line = proc.stdout.readline() if b'statistics' in line: #I don't know what you're doing with the ping stats.
#I'll just print them. For n in range(4): encoding = getattr(sys. Stdout, 'encoding', 'ascii') print(line.
Decode(encoding).rstrip()) line = proc.stdout.readline() print().
Ping is producing many more lines than you're reading due to the 2 second timeout between reads. I'd move the os. Kill call into another thread, and use the main thread to read every line from proc.
Stdout: import sys, os import subprocess import threading import signal import time #Use ctrl-c and ctrl-break to terminate the script/ping def sigbreak(signum, frame): import sys if proc.poll() is None: print('Killing ping...') proc.kill() sys. Exit(0) signal. Signal(signal.
SIGBREAK, sigbreak) signal. Signal(signal. SIGINT, sigbreak) #executes in a separate thread def run(pid): while True: time.
Sleep(2) try: os. Kill(pid, signal. CTRL_BREAK_EVENT) except WindowsError: #quit the thread if ping is dead break cmd = r'c:\windows\system32\ping.
Exe', '127.0.0.1', '-l', '10000', '-t' flags = subprocess. CREATE_NEW_PROCESS_GROUP proc = subprocess. Popen(cmd, stdout=subprocess.
PIPE, creationflags=flags) threading. Thread(target=run, args=(proc. Pid,)).start() while True: line = proc.stdout.readline() if b'statistics' in line: #I don't know what you're doing with the ping stats.
#I'll just print them. For n in range(4): encoding = getattr(sys. Stdout, 'encoding', 'ascii') print(line.
Decode(encoding).rstrip()) line = proc.stdout.readline() print().
Try ping. Py instead of juggling with the ping.exe.
No package size option – user478514 Sep 1 at 10:52.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.