Skip to content

Commit ab6e6f0

Browse files
Documentation and sample updates for clarity and to note the fact that
connection pools now always enable threading.
1 parent fa36066 commit ab6e6f0

File tree

8 files changed

+27
-43
lines changed

8 files changed

+27
-43
lines changed

doc/src/api_manual/deprecations.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ if applicable. The most recent deprecations are listed first.
1818
- Comments
1919
* - `encoding` parameter to :meth:`cx_Oracle.connect()`
2020
- No longer needed as the use of encodings other than UTF-8 is
21-
deprecated.
21+
deprecated. Encoding is handled internally between cx_Oracle and Oracle
22+
Database.
2223
* - `nencoding` parameter to :meth:`cx_Oracle.connect()`
2324
- No longer needed as the use of encodings other than UTF-8 is
2425
deprecated.
@@ -30,13 +31,15 @@ if applicable. The most recent deprecations are listed first.
3031
deprecated.
3132
* - Connection.maxBytesPerCharacter
3233
- No longer needed as the use of encodings other than UTF-8 is
33-
deprecated.
34-
* - positional parmeters to :meth:`cx_Oracle.connect()`
34+
deprecated. The constant value 4 can be used instead.
35+
* - Positional parameters to :meth:`cx_Oracle.connect()`
3536
- Replace with keyword parameters in order to comply with the Python
3637
database API.
37-
* - positional parmeters to :meth:`cx_Oracle.SessionPool()`
38+
* - positional parameters to :meth:`cx_Oracle.SessionPool()`
3839
- Replace with keyword parameters in order to comply with the Python
3940
database API.
41+
* - `threaded` parameter to :meth:`cx_Oracle.SessionPool()`
42+
- The value of this parameter is ignored. Threading is now always used.
4043
* - `waitTimeout` parameter to :meth:`cx_Oracle.SessionPool()`
4144
- Replace with parameter name `wait_timeout`
4245
* - `maxLifetimeSession` parameter to :meth:`cx_Oracle.SessionPool()`
@@ -46,7 +49,7 @@ if applicable. The most recent deprecations are listed first.
4649
* - `maxSessionsPerShard` parameter to :meth:`cx_Oracle.SessionPool()`
4750
- Replace with parameter name `max_sessions_per_shard`
4851
* - `payloadType` parameter to :meth:`Connection.queue()`
49-
- Replace with parameter name `payload_type` if using keyword parmeters.
52+
- Replace with parameter name `payload_type` if using keyword parameters.
5053
* - `ipAddress` parameter to :meth:`Connection.subscribe()`
5154
- Replace with parameter name `ip_address`
5255
* - `groupingClass` parameter to :meth:`Connection.subscribe()`

doc/src/api_manual/module.rst

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ Module Interface
7878

7979
The threaded parameter is expected to be a boolean expression which
8080
indicates whether or not Oracle should wrap accesses to connections with a
81-
mutex. Doing so in single threaded applications imposes a performance
82-
penalty of about 10-15% which is why the default is False.
81+
mutex.
8382

8483
The events parameter is expected to be a boolean expression which indicates
8584
whether or not to initialize Oracle in events mode. This is required for
@@ -250,11 +249,6 @@ Module Interface
250249
:meth:`~SessionPool.acquire()` will create connection objects of that type,
251250
rather than the base type defined at the module level.
252251

253-
The threaded parameter is expected to be a boolean expression which
254-
indicates whether Oracle should wrap accesses to connections with a mutex.
255-
Doing so in single threaded applications imposes a performance penalty of
256-
about 10-15% which is why the default is False.
257-
258252
The getmode parameter indicates whether or not future
259253
:func:`SessionPool.acquire()` calls will wait for available connections. It
260254
can be one of the :ref:`Session Pool Get Modes <sesspoolmodes>` values.
@@ -352,7 +346,8 @@ Module Interface
352346
parameter `sessionCallback` was renamed to `session_callback` and the
353347
parameter `maxSessionsPerShard` was renamed to
354348
`max_sessions_per_shard`. The old names will continue to work as
355-
keyword parameters for a period of time.
349+
keyword parameters for a period of time. The `threaded` parameter value
350+
is ignored and threading is always enabled.
356351

357352

358353
.. function:: Time(hour, minute, second)
@@ -429,7 +424,7 @@ General
429424

430425
Note that in order to make use of multiple threads in a program which
431426
intends to connect and disconnect in different threads, the threaded
432-
parameter to :meth:`connect()` or :meth:`SessionPool()` must be true.
427+
parameter to :meth:`connect()` must be `True`.
433428

434429

435430
.. data:: version

doc/src/release_notes.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Version 8.2 (TBD)
1515
pools. This significantly improves the performance of methods
1616
:meth:`SodaDatabase.createCollection()` (when not specifying a value for
1717
the metadata parameter) and :meth:`SodaDatabase.openCollection()`. Caching
18-
is available when using Oracle Client version 19.11 and higher
18+
is available when using Oracle Client version 19.11 and higher.
1919
#) Added support for supplying hints to SODA operations. A new non-terminal
2020
method :meth:`~SodaOperation.hint()` was added and a `hint` parameter was
2121
added to the methods :meth:`SodaCollection.insertOneAndGet()`,
@@ -26,20 +26,20 @@ Version 8.2 (TBD)
2626
:meth:`cx_Oracle.SessionPool()` in order to permit specifying the size of
2727
the statement cache during the creation of pools and standalone
2828
connections.
29+
#) Threaded mode is now always enabled when creating connection pools with
30+
:meth:`cx_Oracle.SessionPool()`. Any `threaded` parameter value is ignored.
2931
#) Eliminated a memory leak when calling :meth:`SodaOperation.filter()` with a
3032
dictionary.
3133
#) The distributed transaction handle assosciated with the connection is now
3234
cleared on commit or rollback (`issue 530
3335
<https://github.com/oracle/python-cx_Oracle/issues/530>`__).
34-
#) Stop passing unsupported flags to dpiSodaDocCursor_getNext().
3536
#) Added check to ensure that when setting variables or object attributes, the
3637
type of the temporary LOB must match the expected type.
37-
#) In order to follow the PEP 8 naming style a number of parameter names,
38-
method names and attribute names were modified. The old names will be
39-
removed in a subsequent release of cx_Oracle. In addition, the use of
40-
encodings other than UTF-8 is also deprecated. See
41-
:ref:`_deprecations_8_2` for details.
42-
#) Improved test suite.
38+
#) A small number of parameter, method, and attribute names were updated to
39+
follow the PEP 8 style guide. This brings better consistency to the
40+
cx_Oracle API. The old names are still usable but may be removed in a
41+
future release of cx_Oracle. See :ref:`_deprecations_8_2` for details.
42+
#) Improved the test suite.
4343

4444

4545
Version 8.1 (December 2020)

doc/src/user_guide/connection_handling.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,6 @@ for a connection to become available if all are currently in use, for example:
316316
pool = cx_Oracle.SessionPool("hr", userpwd, "dbhost.example.com/orclpdb1",
317317
min=2, max=5, increment=1, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT, encoding="UTF-8")
318318
319-
320-
Applications that are using connections concurrently in multiple threads should
321-
set the ``threaded`` parameter to *True* when creating a connection pool:
322-
323-
.. code-block:: python
324-
325-
# Create the session pool
326-
pool = cx_Oracle.SessionPool("hr", userpwd, "dbhost.example.com/orclpdb1",
327-
min=2, max=5, increment=1, threaded=True, encoding="UTF-8")
328-
329-
330319
See `ConnectionPool.py
331320
<https://github.com/oracle/python-cx_Oracle/tree/master/samples/ConnectionPool.py>`__
332321
for an example.

samples/connection_pool.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# The script uses threading to show multiple users of the pool. One thread
1313
# performs a database sleep while another performs a query. A more typical
1414
# application might be a web service that handles requests from multiple users.
15-
# Applications that use connections concurrently in multiple threads should set
16-
# the 'threaded' parameter to True. Note only one operation (such as an execute
17-
# or fetch) can take place at a time on each connection.
15+
# Note only one operation (such as an execute or fetch) can take place at a time
16+
# on each connection.
1817
#
1918
# Also see session_callback.py.
2019
#
@@ -29,7 +28,7 @@
2928
pool = oracledb.SessionPool(user=sample_env.get_main_user(),
3029
password=sample_env.get_main_password(),
3130
dsn=sample_env.get_connect_string(), min=2,
32-
max=5, increment=1, threaded=True)
31+
max=5, increment=1)
3332

3433
def the_long_query():
3534
with pool.acquire() as conn:

samples/cqn2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def callback(message):
6161
pool = oracledb.SessionPool(user=sample_env.get_main_user(),
6262
password=sample_env.get_main_password(),
6363
dsn=sample_env.get_connect_string(), min=2, max=5,
64-
increment=1, events=True, threaded=True)
64+
increment=1, events=True)
6565
with pool.acquire() as connection:
6666
qos = oracledb.SUBSCR_QOS_QUERY | oracledb.SUBSCR_QOS_ROWIDS
6767
sub = connection.subscribe(callback=callback, timeout=1800, qos=qos)

samples/session_callback.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
33
#------------------------------------------------------------------------------
44

55
#------------------------------------------------------------------------------
@@ -81,8 +81,7 @@ def init_session(conn, requested_tag):
8181
pool = oracledb.SessionPool(user=sample_env.get_main_user(),
8282
password=sample_env.get_main_password(),
8383
dsn=sample_env.get_connect_string(), min=2, max=5,
84-
increment=1, threaded=True,
85-
session_callback=init_session)
84+
increment=1, session_callback=init_session)
8685

8786
# acquire session without specifying a tag; since the session returned is
8887
# newly created, the callback will be invoked but since there is no tag

samples/session_callback_plsql.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
pool = oracledb.SessionPool(user=sample_env.get_main_user(),
3030
password=sample_env.get_main_password(),
3131
dsn=sample_env.get_connect_string(), min=2, max=5,
32-
increment=1, threaded=True,
33-
session_callback="pkg_SessionCallback.TheCallback")
32+
increment=1, session_callback="pkg_SessionCallback.TheCallback")
3433

3534
# truncate table logging calls to PL/SQL session callback
3635
with pool.acquire() as conn:

0 commit comments

Comments
 (0)