一个主类调用另外两个类(IperfServer 和 IperfClient),我正在尝试使用多线程运行它们。我正在为 iperf3 使用 python 包装类。两个类都已启动,但在运行 Iperf 时,出现分段错误。
代码片段:
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()
输出:
3
1
分段故障
我是python和多线程的新手。有人可以帮我弄清楚我犯的错误吗?