I have a simple python script that continuously runs iperf3. Currently, only the first request works. The second request throws an error 'unable to send cookie to server' This is on an ubuntu 20 server The script is as follows:
!/usr/bin/python3
import iperf3
import time
client = iperf3.Client()
client.duration=1
#client.bind_address='172.17.0.2'
#client.server_hostname='192.168.5.108'
client.bind_address='localhost'
client.server_hostname='localhost'
client.port=5201
client.blksize = 1234
client.num_streams = 10
client.zerocopy = True
client.verbose = False
client.reverse = False
while True:
result = client.run()
time.sleep(3)
print(result)
On the server side I just run iperf3 -s
There might be a bug in the iperf3 Python wrapper that prevents running the same
Clientobject multiple times.What worked for me as a workaround is to create a new
Clientinside the loop and always destroy it at the end (in order to free all resources):NOTE: Running
del clientusually triggers immediate garbage collection (depending on specific Python interpreter) which should run needed cleanup tasks. However, Python GC is not guaranteed to run immediately, so this might not always work. You might consider trigerring GC manually...See also related Github issue discussion.