A main class calls two other classes(IperfServer and IperfClient) and I'm trying to run them using multithreading. I am using the python wrapper class for iperf3. Both the classes are initiated but while running Iperf, I get segmentation Fault.
CODE SNIPPET:
class IperfServer(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
print("1")
server = iperf3.Server()
print("2")
server.port = 5201
response = server.run()
class IperfClient(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
print("3")
connection = http.client.HTTPSConnection("abc.efg")
print("4")
connection.request(method="GET", url="/hij/")
response = connectn.getresponse()
connectn.close()
print("5")
client = iperf3.Client()
client.run()
class IperfAgent(object):
thread1 = IperfClient()
thread2 = IperfServer()
thread1.start()
thread2.start()
OUTPUT:
3
1
Segmentation Fault
I'm a newbie to python and multithreading. Could someone help me figure out the mistake I am making?
Try running it in a subprocess (see multiprocessing.Process) instead of a thread.
It appears that iperf_defaults requires being run on a main thread.