Re: [External] : callTimeout takes no effect (cx_Oracle 8.1; Oracle client 18.3)

Zongheng Yang <[email protected]> Thu, 22 Apr 2021 15:59:19 -0700
Newsgroups gmane.comp.python.db.cx-oracle
Message-ID <CAG2+eohUuCrVgpc8BHzf=RT-eVJKN6jnnKTCm5SYmXSU94TPqQ@mail.gmail.com>
--===============3661120285939469996==
Content-Type: multipart/alternative; boundary="000000000000bf3d1605c097a1f7"

--000000000000bf3d1605c097a1f7
Content-Type: text/plain; charset="UTF-8"

Thanks for the quick response!

(base) [oracle@oracle-test18 ~]$ grep disable_oob
$ORACLE_HOME/network/admin/sqlnet.ora
#disable_oob = ON
disable_oob = ON

With this change, and running SHUTDOWN then STARTUP, the same issue
persists.  No timeout effect.


On Thu, Apr 22, 2021 at 3:51 PM Christopher Jones <
[email protected]> wrote:

>
> On 23/4/21 8:44 am, ConcreteVitamin wrote:
>
> 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?
>
> Start by setting disable_oob=on in a sqlnet.ora file on your Python
> machine. The OOB setting is a common gotcha. See
> https://cx-oracle.readthedocs.io/en/latest/user_guide/initialization.html#optional-oracle-client-configuration-files
>
> Or upgrade to 19c Oracle client libraries, which auto-detect the necessary
> OOB setting.
>
> -- https://twitter.com/ghrd
>
> _______________________________________________
> cx-oracle-users mailing list
> cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
>

--000000000000bf3d1605c097a1f7
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Thanks for the quick response!</div><div><br></div>(b=
ase) [oracle@oracle-test18 ~]$ grep disable_oob $ORACLE_HOME/network/admin/=
sqlnet.ora<br>#disable_oob =3D ON<br>disable_oob =3D ON<br><div><br></div><=
div>With this change, and running SHUTDOWN then STARTUP, the same issue per=
sists.=C2=A0 No timeout effect.</div><div><br></div></div><br><div class=3D=
"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, Apr 22, 2021 at=
 3:51 PM Christopher Jones &lt;<a href=3D"mailto:[email protected]=
om">[email protected]</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex">

 =20
  <div>
    <p><br>
    </p>
    <div>On 23/4/21 8:44 am, ConcreteVitamin
      wrote:<br>
    </div>
    <blockquote type=3D"cite">
     =20
      <div dir=3D"ltr">Hi,
        <div><br>
        </div>
        <div>I&#39;m using the following script, modified from
          samples/CallTimeout.py (changing into
          cx_Oracle.connect(mode=3Dcx_Oracle.SYSDBA) &amp; using a 500ms
          timeout), and <b>callTimeout is not taking effects</b>:</div>
        <div><br>
        </div>
        <blockquote style=3D"margin:0px 0px 0px 40px;border:none;padding:0p=
x">
          <div><font face=3D"monospace">import cx_Oracle</font></div>
          <div><font face=3D"monospace">print(cx_Oracle.version,
              cx_Oracle.clientversion())</font></div>
          <div><font face=3D"monospace"><br>
            </font></div>
          <div><font face=3D"monospace">connection =3D
              cx_Oracle.connect(mode=3Dcx_Oracle.SYSDBA)</font></div>
          <div><font face=3D"monospace"><br>
            </font></div>
          <div><font face=3D"monospace">connection.callTimeout =3D 500</fon=
t></div>
          <div><font face=3D"monospace">print(&quot;Call timeout set at&quo=
t;,
              connection.callTimeout, &quot;milliseconds...&quot;)</font></=
div>
          <div><font face=3D"monospace"><br>
            </font></div>
          <div><font face=3D"monospace">cursor =3D connection.cursor()</fon=
t></div>
          <div><font face=3D"monospace">cursor.execute(&quot;select sysdate
              from dual&quot;)</font></div>
          <div><font face=3D"monospace">today, =3D cursor.fetchone()</font>=
</div>
          <div><font face=3D"monospace">print(&quot;Fetch of current date
              before timeout:&quot;, today)</font></div>
          <div><font face=3D"monospace"><br>
            </font></div>
          <div><font face=3D"monospace"># dbms_session.sleep() replaces
              dbms_lock.sleep() from Oracle Database 18c</font></div>
          <div><font face=3D"monospace">sleep_proc_name =3D
              &quot;dbms_session.sleep&quot; \</font></div>
          <div><font face=3D"monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 if
              int(connection.version.split(&quot;.&quot;)[0]) &gt;=3D 18 \<=
/font></div>
          <div><font face=3D"monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 else &q=
uot;dbms_lock.sleep&quot;</font></div>
          <div><font face=3D"monospace"><br>
            </font></div>
          <div><font face=3D"monospace">print(&quot;Sleeping...should time
              out...&quot;)</font></div>
          <div><font face=3D"monospace">try:</font></div>
          <div><font face=3D"monospace">=C2=A0 =C2=A0
              cursor.callproc(sleep_proc_name, (3,))</font></div>
          <div><font face=3D"monospace">except cx_Oracle.DatabaseError as
              e:</font></div>
          <div><font face=3D"monospace">=C2=A0 =C2=A0 print(&quot;ERROR:&qu=
ot;, e)</font></div>
          <div><font face=3D"monospace"><br>
            </font></div>
          <div><font face=3D"monospace">cursor.execute(&quot;select sysdate
              from dual&quot;)</font></div>
          <div><font face=3D"monospace">today, =3D cursor.fetchone()</font>=
</div>
          <div><font face=3D"monospace">print(&quot;Fetch of current date a=
fter
              timeout:&quot;, today)</font></div>
        </blockquote>
        <div><br>
        </div>
        <div>The output is:</div>
        <div><br>
        </div>
        <blockquote style=3D"margin:0px 0px 0px 40px;border:none;padding:0p=
x">
          <div><font face=3D"monospace">$ python test.py</font></div>
          <div><font face=3D"monospace">8.1.0 (18, 3, 0, 0, 0)</font></div>
          <div><font face=3D"monospace">Call timeout set at 500
              milliseconds...</font></div>
          <div><font face=3D"monospace">Fetch of current date before
              timeout: 2021-04-22 22:39:30</font></div>
          <div><font face=3D"monospace">Sleeping...should time out...</font=
></div>
          <div><font face=3D"monospace">Fetch of current date after
              timeout: 2021-04-22 22:39:33</font></div>
        </blockquote>
        <div><br>
        </div>
        <div>Note that (from the output), I&#39;m using <b>cx_Oracle 8.1
            and Oracle client library 18.3</b> --- both satisfy this
          feature&#39;s=C2=A0requirements.=C2=A0 The DB is freshly installe=
d on an
          Oracle Linux box.</div>
        <div><br>
        </div>
        <div>Is there a pointer on how to resolve this?=C2=A0 <b>Is it
            possible something about=C2=A0connect(mode=3Dcx_Oracle.SYSDBA) =
made
            the timeout a no-op?=C2=A0 </b>Or, should I upgrade to Oracle 1=
9
          and retry?</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    <p>Start by setting <font face=3D"monospace">disable_oob=3Don</font> in
      a sqlnet.ora file on your Python machine. The OOB setting is a
      common gotcha. See
<a href=3D"https://cx-oracle.readthedocs.io/en/latest/user_guide/initializa=
tion.html#optional-oracle-client-configuration-files" target=3D"_blank">htt=
ps://cx-oracle.readthedocs.io/en/latest/user_guide/initialization.html#opti=
onal-oracle-client-configuration-files</a></p>
    <p> Or upgrade to 19c Oracle client libraries, which auto-detect the
      necessary OOB setting.<br>
    </p>
    <pre cols=3D"150">--=20
<a href=3D"https://twitter.com/ghrd" target=3D"_blank">https://twitter.com/=
ghrd</a>
</pre>
  </div>

_______________________________________________<br>
cx-oracle-users mailing list<br>
<a href=3D"mailto:cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org" target=3D"_blank">=
cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/cx-oracle-users" re=
l=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/list=
info/cx-oracle-users</a><br>
</blockquote></div>

--000000000000bf3d1605c097a1f7--


--===============3661120285939469996==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============3661120285939469996==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
cx-oracle-users mailing list
cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/cx-oracle-users

--===============3661120285939469996==--