1 Reply Latest reply on Nov 15, 2010 10:05 PM by cj

    Problem with cx_Oracle.execute()

      Hi, everybody!
      I've encountered the following problem while using cx_Oracle extension for my Python programme: method cx_Oracle.execute() hangs with no response or errors in case of sudden loss of net connection. Here is my special simple code for testing this bug:

      import cx_Oracle
      connstr = raw_input('connstr:') # in a form of 'user/passwd@host'
      con = cx_Oracle.connect(connstr)
      cursor = con.cursor()
      query = raw_input('query:') # Let's print query (for example 'select * from table1'), then switch the internet connection off and push Enter
      cursor.execute(query) # here it hangs
      print 'Here' # it won't be printed
      res = cursor.fetchall()
      print res

      In presence of the Internet? all's OK.
      by the way, MySQLdb - a python extension for MySQL databases rises operational error in such case ( mysqlexceptions.OperationalError: (2006, 'MySQL server has gone away')), which might be easily processed.
      If it helps: I've got Linux Fedora 14, Python 2.7, cx_Oracle-5.0.4
      Please help if possible.
      Thanx in advance!
        • 1. Re: Problem with cx_Oracle.execute()
          I'd initially suspect this is a feature of the underlying network layer and not particularly related to cx_Oracle.

          You might want to look at the fantastically named ENABLE=BROKEN feature of Oracle Net and/or adjust your
          TCP stack keepalive parameters.

          See http://download.oracle.com/docs/cd/E11882_01/network.112/e10835/tnsnames.htm#NETRF431