We've got a command line application that can occasionally perform long queries that we'd like to have the ability to kill. According to the mysql docs, the proper way to handle this is to set a SIGALRM/SIGINT signal handler that longjmps out of the query after it's taken a while. MySQLdb doesn't appear to support this though. Furthermore, python and signals don't play that well together, anyway. So, how do the rest of you deal with this?
I suppose timeouts can be done by spawning off a thread to run the query, and have the main thread wait X seconds or less and see if the query finished. However, won't this not work with catching the SIGINT?
Thanks for your help!
-e
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
We've got a command line application that can occasionally perform long queries that we'd like to have the ability to kill. According to the mysql docs, the proper way to handle this is to set a SIGALRM/SIGINT signal handler that longjmps out of the query after it's taken a while. MySQLdb doesn't appear to support this though. Furthermore, python and signals don't play that well together, anyway. So, how do the rest of you deal with this?
I suppose timeouts can be done by spawning off a thread to run the query, and have the main thread wait X seconds or less and see if the query finished. However, won't this not work with catching the SIGINT?
Thanks for your help!
-e