pytyrant-timeout.patch
解决pytyrant.py socket 超时的问题
Index: pytyrant.py
===================================================================
--- pytyrant.py (revision 55325)
+++ pytyrant.py (revision 55326)
@@ -173,7 +173,6 @@
if fail_code:
raise TyrantError(fail_code)
-
def socklen(sock):
return struct.unpack('>I', sockrecv(sock, 4))[0]
@@ -353,12 +352,13 @@
class Tyrant(object):
@[classmethod](/name/classmethod)
- def open(cls, host='127.0.0.1', port=DEFAULT_PORT):
+ def open(cls, host='127.0.0.1', port=DEFAULT_PORT, timeout=3.0):
sock = socket.socket()
+ sock.settimeout(timeout)
sock.connect((host, port))
sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
return cls(sock)
-
+
def __init__(self, sock):
self.sock = sock
0
Nearby
- 上一篇 › [referer-parser]一个来路分析工具
- 下一篇 › python不同方法倒转一个list 的效率对比