本文整理匯總了Python中socket.gettimeout方法的典型用法代碼示例。如果您正苦於以下問題:Python socket.gettimeout方法的具體用法?Python socket.gettimeout怎麽用?Python socket.gettimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類socket
的用法示例。
在下文中一共展示了socket.gettimeout方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testFloatReturnValue
# 需要導入模塊: import socket [as 別名]
# 或者: from socket import gettimeout [as 別名]
def testFloatReturnValue(self):
# Test return value of gettimeout()
self.sock.settimeout(7.345)
self.assertEqual(self.sock.gettimeout(), 7.345)
self.sock.settimeout(3)
self.assertEqual(self.sock.gettimeout(), 3)
self.sock.settimeout(None)
self.assertEqual(self.sock.gettimeout(), None)
示例2: testObjectCreation
# 需要導入模塊: import socket [as 別名]
# 或者: from socket import gettimeout [as 別名]
def testObjectCreation(self):
# Test Socket creation
self.assertEqual(self.sock.gettimeout(), None,
"timeout not disabled by default")
示例3: testReturnType
# 需要導入模塊: import socket [as 別名]
# 或者: from socket import gettimeout [as 別名]
def testReturnType(self):
# Test return type of gettimeout()
self.sock.settimeout(1)
self.assertEqual(type(self.sock.gettimeout()), type(1.0))
self.sock.settimeout(3.9)
self.assertEqual(type(self.sock.gettimeout()), type(1.0))
示例4: testTimeoutThenBlocking
# 需要導入模塊: import socket [as 別名]
# 或者: from socket import gettimeout [as 別名]
def testTimeoutThenBlocking(self):
# Test settimeout() followed by setblocking()
self.sock.settimeout(10)
self.sock.setblocking(1)
self.assertEqual(self.sock.gettimeout(), None)
self.sock.setblocking(0)
self.assertEqual(self.sock.gettimeout(), 0.0)
self.sock.settimeout(10)
self.sock.setblocking(0)
self.assertEqual(self.sock.gettimeout(), 0.0)
self.sock.setblocking(1)
self.assertEqual(self.sock.gettimeout(), None)
示例5: testBlockingThenTimeout
# 需要導入模塊: import socket [as 別名]
# 或者: from socket import gettimeout [as 別名]
def testBlockingThenTimeout(self):
# Test setblocking() followed by settimeout()
self.sock.setblocking(0)
self.sock.settimeout(1)
self.assertEqual(self.sock.gettimeout(), 1)
self.sock.setblocking(1)
self.sock.settimeout(1)
self.assertEqual(self.sock.gettimeout(), 1)