本文整理匯總了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)