1

I'm trying to get the Oracle inbuilt timeout attribute to work in Python.

Some relevant docs are here: https://cx-oracle.readthedocs.io/en/latest/connection.html

import cx_Oracle
connection = cx_Oracle.connect("user/pass@thedb")
connection.callTimeout = 2000
cursor = connection.cursor()

The trouble is that the initial connection command is the one that is taking an excessive period to timeout (several minutes).

My question is, is there a way to somehow apply the callTimeout before the connection is made? or is there another way to do what I want?

I'm aware of this help: Set database connection timeout in Python It seems excessive to use threads for this.

aghsmith
  • 265
  • 3
  • 11
  • The answer from BetarU on the linked question does not work for you? – thebjorn Apr 30 '19 at 17:20
  • Hi, I would prefer not to have the extra dependency on the sqlalchemy module (which isn'd default). However, I don't think the given example will help as t = threading.Timer(timeout,conn.cancel) call occurs after the connection object has been created. This is the stage I'm trying to sort out. It occurs if I'm in the wrong location, without db access. – aghsmith Apr 30 '19 at 20:01
  • 1
    That has nothing to do with BetarU's answer, which simply said: "In linux see /etc/oracle/sqlnet.ora, `sqlnet.outbound_connect_timeout= value`" – thebjorn Apr 30 '19 at 22:03
  • Thanks for pointing this out. I'm using Windows... which shouldn't matter. I tried modifying my sqlnet.ora file, but this didn't help. All three of the suggested parameters set to 1 :( – aghsmith Apr 30 '19 at 23:02

0 Answers0