Forum Stats

  • 3,769,560 Users
  • 2,252,976 Discussions
  • 7,875,084 Comments

Discussions

Problem with cx_Oracle.execute()

813954
813954 Member Posts: 1
edited Nov 15, 2010 5:05PM in Python
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/[email protected]'
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!
Yury.
Tagged:

Answers

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,643 Employee
    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
This discussion has been closed.