本文整理汇总了Python中terminator.Terminator.terminate方法的典型用法代码示例。如果您正苦于以下问题:Python Terminator.terminate方法的具体用法?Python Terminator.terminate怎么用?Python Terminator.terminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类terminator.Terminator
的用法示例。
在下文中一共展示了Terminator.terminate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: database
# 需要导入模块: from terminator import Terminator [as 别名]
# 或者: from terminator.Terminator import terminate [as 别名]
#.........这里部分代码省略.........
# Get views, functions, procedures, and triggers.
state.views = self.execute_sql(
"SELECT table_name FROM information_schema.views"
).results
state.functions = self.execute_sql(
"SELECT routine_name FROM information_schema.routines "
"WHERE routine_type='FUNCTION'"
).results
state.procedures = self.execute_sql(
"SELECT routine_name FROM information_schema.routines "
"WHERE routine_type='PROCEDURE'"
).results
state.triggers = self.execute_sql(
"SELECT trigger_name FROM information_schema.triggers"
).results
except (mysql.connector.errors.Error, DatabaseError, TimeoutError):
raise
return state
def kill_query(self):
"""
Function: kill_query
--------------------
Kills the running query by terminating the connection.
"""
if not self.db or not self.db.is_connected():
return
thread_id = self.db.connection_id
try:
self.terminator.terminate(thread_id)
except mysql.connector.errors.Error:
err("Unable to kill %d (was probably already killed)." % thread_id)
# If the terminator doesn't even exist, then this is a problem.
except AttributeError:
err("Terminator doesn't exist to kill queries!", True)
self.savepoints = []
def purge_db(self):
"""
Function: purge_db
------------------
Remove everything from the database.
"""
state = self.get_state()
self.reset_state(DatabaseState(), state)
def release(self, savepoint):
"""
Function: release
-----------------
Releases the named savepoint.
savepoint: The savepoint to release.
"""
if savepoint not in self.savepoints:
return
self.savepoints.remove(savepoint)
try:
self.execute_sql("RELEASE SAVEPOINT %s" % savepoint)