python多线程运行问题(sleep作用)
这是用scapy写了发送arp包,为了解析本地网络有哪些设备
from time import sleep
from scapy.all import srp, Ether, ARP,conf
from concurrent.futures.thread import ThreadPoolExecutor
from threading import current_thread
# 只需解析到对方的mac地址即可
conf.verb = 0
本文探讨了在Python中使用多线程发送ARP包时遇到的问题。当直接调用时,程序运行正常,但在多线程环境下,由于缺少适当的同步机制,导致无法获取返回结果。通过在多线程中加入time.sleep(1)后,程序能够正确返回结果。文章主要关注线程同步和sleep函数在多线程中的应用。
python多线程运行问题(sleep作用)
这是用scapy写了发送arp包,为了解析本地网络有哪些设备
from time import sleep
from scapy.all import srp, Ether, ARP,conf
from concurrent.futures.thread import ThreadPoolExecutor
from threading import current_thread
# 只需解析到对方的mac地址即可
conf.verb = 0
2670

被折叠的 条评论
为什么被折叠?