本文整理汇总了Python中DBUtils.SteadyDB.connect._ping_check方法的典型用法代码示例。如果您正苦于以下问题:Python connect._ping_check方法的具体用法?Python connect._ping_check怎么用?Python connect._ping_check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtils.SteadyDB.connect
的用法示例。
在下文中一共展示了connect._ping_check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test11_ConnectionPingCheck
# 需要导入模块: from DBUtils.SteadyDB import connect [as 别名]
# 或者: from DBUtils.SteadyDB.connect import _ping_check [as 别名]
def test11_ConnectionPingCheck(self):
Connection.has_ping = False
Connection.num_pings = 0
db = SteadyDBconnect(dbapi)
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 0)
db.close()
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 0)
self.assert_(db._ping_check() is None)
self.assertEqual(Connection.num_pings, 1)
db = SteadyDBconnect(dbapi, ping=7)
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 2)
db.close()
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 2)
self.assert_(db._ping_check() is None)
self.assertEqual(Connection.num_pings, 2)
Connection.has_ping = True
db = SteadyDBconnect(dbapi)
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 2)
db.close()
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 2)
self.assert_(db._ping_check())
self.assertEqual(Connection.num_pings, 3)
db = SteadyDBconnect(dbapi, ping=1)
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 3)
db.close()
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 3)
self.assert_(db._ping_check())
self.assertEqual(Connection.num_pings, 4)
db.close()
self.assert_(db._ping_check())
self.assertEqual(Connection.num_pings, 5)
db = SteadyDBconnect(dbapi, ping=7)
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 7)
db.close()
db.cursor().execute('select test')
self.assertEqual(Connection.num_pings, 9)
db = SteadyDBconnect(dbapi, ping=3)
self.assertEqual(Connection.num_pings, 9)
db.cursor()
self.assertEqual(Connection.num_pings, 10)
db.close()
cursor = db.cursor()
self.assertEqual(Connection.num_pings, 11)
cursor.execute('select test')
self.assertEqual(Connection.num_pings, 11)
db = SteadyDBconnect(dbapi, ping=5)
self.assertEqual(Connection.num_pings, 11)
db.cursor()
self.assertEqual(Connection.num_pings, 11)
db.close()
cursor = db.cursor()
self.assertEqual(Connection.num_pings, 11)
cursor.execute('select test')
self.assertEqual(Connection.num_pings, 12)
db.close()
cursor = db.cursor()
self.assertEqual(Connection.num_pings, 12)
cursor.execute('select test')
self.assertEqual(Connection.num_pings, 13)
db = SteadyDBconnect(dbapi, ping=7)
self.assertEqual(Connection.num_pings, 13)
db.cursor()
self.assertEqual(Connection.num_pings, 14)
db.close()
cursor = db.cursor()
self.assertEqual(Connection.num_pings, 15)
cursor.execute('select test')
self.assertEqual(Connection.num_pings, 16)
db.close()
cursor = db.cursor()
self.assertEqual(Connection.num_pings, 17)
cursor.execute('select test')
self.assertEqual(Connection.num_pings, 18)
db.close()
cursor.execute('select test')
self.assertEqual(Connection.num_pings, 20)
Connection.has_ping = False
Connection.num_pings = 0