Skip to content
Advertisement

How to support Command Time out in mysql version 5.6? I am looking for a CommandTimeout option similar to that of ADO .NET but in python

I am new to python and would like to do what ADO .NET CommandTimeout property does (setting the execution time for a query) in mysql (5.6).

I am looking for any in-built python libraries that may support it by default (I have tried pymysql, pyodbc and mysql.connector) or what could the best way to do this, in case I have to invent the wheel from scratch.

I am working with an old mysql version (5.6), and the reason I am stressing on this is that on researching I have found out that this could be accomplished in mysql 5.7 onwards by using the following commands

JavaScript

Reference Links I have already gone through which suggests a solution in mysql 5.7 and upwards: http://mysqlserverteam.com/server-side-select-statement-timeouts/ https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html#optimizer-hints-execution-time

But I am looking for a solution in mysql 5.6, Thanks in advance.

Advertisement

Answer

So I was finally able to solve the issue, by creating a thread/process which is invoked based on a timer as follows:

JavaScript

The thread would get all the processes created by the current user and who is executing for time more than the command timeout and kill the ones that exist:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement