def test_in_flight_is_one(self):
"""
Verify that in_flight value stays equal to one while doing multiple inserts.
The number of inserts can be set through INSERTS_ITERATIONS environmental variable.
Default value is 1000000.
"""
prepared = self.session.prepare("INSERT INTO race (x) VALUES (?)")
iterations = int(os.getenv("INSERT_ITERATIONS", 1000000))
i = 0
leaking_connections = False
while i < iterations and not leaking_connections:
bound = prepared.bind((i,))
self.session.execute(bound)
for pool in self.session._pools.values():
if leaking_connections:
break
for conn in pool.get_connections():
if conn.in_flight > 1:
print(self.session.get_pool_state())
leaking_connections = True
break
i = i + 1
self.assertFalse(leaking_connections, 'Detected leaking connection after %s iterations' % i)
test_multi_inserts.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录