实例没有di

2024-05-20 05:47:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我有3个设备。设备A与设备C通信。设备B嗅探连接。我的代码工作得很好,但我不明白为什么decoder对象在线程退出后(即,当controlTrue时)继续嗅探连接

解码器类对设备A和C之间的数据包进行解码,并且没有任何循环机制(当它作为单个脚本运行时,它运行一次然后退出)

下面是代码的简化版本(在设备B上运行),问题在于:

class Thread_Class(Flag):
    def run(self):
        while(control == False):
            self.parent.object.loop(0, self.handle_packets)

    def handle_packets(self, ...):
        # packet handling code using pcapy library
        packet = ...

        self.parent.decoder = Decoder(self)
        self.parent.decoder.decode(packet)

Tags: 对象代码selftruepacketdef解码器解码