我需要在Python的socket recv方法上设置超时。如何实现?
向 https://boltons.readthedocs.io/en/latest/socketutils.html 致敬。
它提供了一个缓冲套接字,这提供了许多非常有用的功能,例如:
.recv_until() #recv until occurrence of bytes
.recv_closed() #recv until close
.peek() #peek at buffer but don't pop values
.settimeout() #configure timeout (including recv timeout)