Python开放dis示例未按预期运行



我正试图让打开的dis-python包在我的机器上正确运行。我正在运行Python 3.8。

使用pip,我从它的源代码编译包,如下所示:pip install .

之后,按照文件中的说明。我运行python dis_receiver.py

我立即遇到了这个错误:

Created UDP socket 3001
Traceback (most recent call last):
File "dis_receiver.py", line 40, in <module>
recv()
File "dis_receiver.py", line 27, in recv
data = udpSocket.recv(1024) # buffer size in bytes
socket.timeout: timed out

我真的不明白为什么会发生这种情况,因为我对文档化的示例过程完全没有改变。知道为什么会发生这种事吗?

原来套接字超时设置为在3s后过期。此处设置:

udpSocket.settimeout(3) # exit if we get nothing in this many seconds

只需将其更改为一个更高的数字,就可以给自己一些额外的时间,不再有套接字超时。

udpSocket.settimeout(20000) # exit if we get nothing in this many seconds

最新更新