Skip to content

Commit ab4cde0

Browse files
Use "wait" mode for acquiring connections from the pool in order to avoid
potential errors under certain circumstances.
1 parent 4db5328 commit ab4cde0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/SessionPool.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ def testRollbackOnRelease(self):
109109

110110
def testThreading(self):
111111
"""test session pool to database with multiple threads"""
112-
self.pool = cx_Oracle.SessionPool(USERNAME, PASSWORD, TNSENTRY, 5, 20,
113-
2, threaded = True, encoding = ENCODING, nencoding = NENCODING)
112+
self.pool = cx_Oracle.SessionPool(USERNAME, PASSWORD, TNSENTRY,
113+
min = 5, max = 20, increment = 2, threaded = True,
114+
getmode = cx_Oracle.SPOOL_ATTRVAL_WAIT, encoding = ENCODING,
115+
nencoding = NENCODING)
114116
threads = []
115117
for i in range(20):
116118
thread = threading.Thread(None, self.__ConnectAndDrop)
@@ -121,8 +123,10 @@ def testThreading(self):
121123

122124
def testThreadingWithErrors(self):
123125
"""test session pool to database with multiple threads (with errors)"""
124-
self.pool = cx_Oracle.SessionPool(USERNAME, PASSWORD, TNSENTRY, 5, 20,
125-
2, threaded = True, encoding = ENCODING, nencoding = NENCODING)
126+
self.pool = cx_Oracle.SessionPool(USERNAME, PASSWORD, TNSENTRY,
127+
min = 5, max = 20, increment = 2, threaded = True,
128+
getmode = cx_Oracle.SPOOL_ATTRVAL_WAIT, encoding = ENCODING,
129+
nencoding = NENCODING)
126130
threads = []
127131
for i in range(20):
128132
thread = threading.Thread(None, self.__ConnectAndGenerateError)

0 commit comments

Comments
 (0)