[cx-oracle-users] callTimeout takes no effect (cx_Oracle 8.1; Oracle client 18.3)
Brought to you by:
atuining
|
From: ConcreteVitamin <con...@gm...> - 2021-04-22 22:45:11
|
Hi,
I'm using the following script, modified from samples/CallTimeout.py
(changing into cx_Oracle.connect(mode=cx_Oracle.SYSDBA) & using a 500ms
timeout), and *callTimeout is not taking effects*:
import cx_Oracle
print(cx_Oracle.version, cx_Oracle.clientversion())
connection = cx_Oracle.connect(mode=cx_Oracle.SYSDBA)
connection.callTimeout = 500
print("Call timeout set at", connection.callTimeout, "milliseconds...")
cursor = connection.cursor()
cursor.execute("select sysdate from dual")
today, = cursor.fetchone()
print("Fetch of current date before timeout:", today)
# dbms_session.sleep() replaces dbms_lock.sleep() from Oracle Database 18c
sleep_proc_name = "dbms_session.sleep" \
if int(connection.version.split(".")[0]) >= 18 \
else "dbms_lock.sleep"
print("Sleeping...should time out...")
try:
cursor.callproc(sleep_proc_name, (3,))
except cx_Oracle.DatabaseError as e:
print("ERROR:", e)
cursor.execute("select sysdate from dual")
today, = cursor.fetchone()
print("Fetch of current date after timeout:", today)
The output is:
$ python test.py
8.1.0 (18, 3, 0, 0, 0)
Call timeout set at 500 milliseconds...
Fetch of current date before timeout: 2021-04-22 22:39:30
Sleeping...should time out...
Fetch of current date after timeout: 2021-04-22 22:39:33
Note that (from the output), I'm using *cx_Oracle 8.1 and Oracle client
library 18.3* --- both satisfy this feature's requirements. The DB is
freshly installed on an Oracle Linux box.
Is there a pointer on how to resolve this? *Is it possible something
about connect(mode=cx_Oracle.SYSDBA) made the timeout a no-op? *Or, should
I upgrade to Oracle 19 and retry?
Thanks.
|