Hi all,
Refer on the code below, I’m trying to ping a site using subprocess.Popen, the expected result is to have the outputs from the console (i.e. Request Timed Out, packets sent/received, etc) be written on a string memory tag. However, nothing is being written on the tag, it seems like the thread is getting lost in the process.
The script is being executed on a timer with the following configuration:
- Delay Type: Fixed Delay
- Delay (ms): 30,000
- Threading: Dedicated
Code:
import subprocess
def ping():
system.tag.writeAsync(paths, values)
proc = subprocess.Popen(["ping", "-c", "1", "-i", "180", "google.com"], shell=False, stdout=subprocess.PIPE)
outs,err = proc.communicate()
paths = ["[default]Trial Site/Connectivity/Latency"]
values = [outs]
system.tag.writeAsync(paths, values)
ping()
Please let me know if you need additional information.
Cheers!