我有3个设备。设备A与设备C通信。设备B嗅探连接。我的代码工作得很好,但我不明白为什么decoder
对象在线程退出后(即,当control
是True
时)继续嗅探连接
解码器类对设备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)
好吧,我解决了。。。我在最后两行周围放了一个
if control == False
相关问题 更多 >
编程相关推荐