def testReadTimeout(self):
"""Test if read timeouts work and group_read operations
group_read operations should never block
"""
tunnel = KNXIPTunnel(gwip)
tunnel.connect()
# Read from some random address and hope nothing responds here
tick = datetime.now()
res = tunnel.group_read(37000, timeout=1)
tock = datetime.now()
diff = tock - tick # the result is a datetime.timedelta object
self.assertTrue(diff.total_seconds() >= 1 and diff.total_seconds() < 3)
self.assertIsNone(res)
# Read from some random address and hope nothing responds here
tick = datetime.now()
res = tunnel.group_read(37000, timeout=5)
tock = datetime.now()
diff = tock - tick # the result is a datetime.timedelta object
self.assertTrue(diff.total_seconds() >= 5 and diff.total_seconds() < 6)
self.assertIsNone(res)
tunnel.disconnect()
评论列表
文章目录