thiezn / iperf3-python

Python wrapper around iperf3
https://iperf3-python.readthedocs.org/
MIT License
109 stars 52 forks source link

json_output = False, always will output "None" #38

Closed VasiliyRusin closed 5 years ago

VasiliyRusin commented 5 years ago

There is my function

def start_test(hostname, port):
    client = iperf3.Client()
    client.duration = 1
    client.reverse = True
    client.num_streams = 16
    client.server_hostname = hostname
    client.port = port
    client.json_output = False
    return client.run()

If I set client.json_output = False, I will get "None". If I set output as json, everything work like a charm.

iperf version:

iperf 3.1.3 Linux vasiliyrusin 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 Optional features available: CPU affinity setting, IPv6 flow label, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing

thiezn commented 5 years ago

Hi @VasiliyRusin

This is by design, when you set json_output to False it will print the results to stdout/stderr. See docs here: https://iperf3-python.readthedocs.io/en/latest/modules.html#iperf3.IPerf3.json_output

If you want to capture the output in a variable you will need to catch the stdout output and store it.