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:
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()
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!
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.