mysqldb execute timeout

Discussion in 'Python' started by Carles Pina i Estany, Apr 20, 2007.

  1. 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,

    --
    Carles Pina i Estany GPG id: 0x8CBDAE64
    http://pinux.info
    Carles Pina i Estany, Apr 20, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sheila King

    MySQLdb: execute query results...

    Sheila King, Sep 1, 2003, in forum: Python
    Replies:
    1
    Views:
    2,653
    Sheila King
    Sep 1, 2003
  2. Tim Williams
    Replies:
    2
    Views:
    633
    Tim Williams
    May 28, 2004
  3. John Nagle
    Replies:
    20
    Views:
    652
    M.-A. Lemburg
    Feb 7, 2008
  4. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,271
    Brian Candler
    Oct 6, 2004
  5. Íßêïò Ãêñ33ê

    Cannot run a single MySQLdb execute....

    Íßêïò Ãêñ33ê, Mar 28, 2013, in forum: Python
    Replies:
    25
    Views:
    329
Loading...

Share This Page