mysqldb execute timeout

  • Thread starter Carles Pina i Estany
  • Start date
C

Carles Pina i Estany

Hello,

I need to implement timeout for execute method in Mysql queries. I am using
MySQLdb.

I have tried it:
signal.signal(signal.SIGALRM,handler)
signal.alarm(1)
cursor.execute(sql)
signal.alarm(0)

But handler is never executed. In other example (changing cursor.execute by
time.sleep(5)) it is executed. Maybe execute disables signals? In Perl it is
disabled b ut there is a way to use.

I found it:
http://mail.python.org/pipermail/tutor/2002-July/015343.html
And:
http://www.timo-tasi.org/python/timeoutsocket.py

I prefer to use alarm method (more clear, less instrusive, I only need it)

Any way how to do? I will read now tmieoutsocket.py to learn some way,
but they are not using signals or alarms.

Thank you very much,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top