blob: fd02f9139527a5f787feb62bdd7fa100957e47fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
from sqlalchemy.pool import QueuePool
from sqlalchemy.testing import AssertsExecutionResults
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import profiling
pool = None
class QueuePoolTest(fixtures.TestBase, AssertsExecutionResults):
__requires__ = ("cpython", "python_profiling_backend")
class Connection(object):
def rollback(self):
pass
def close(self):
pass
def setup(self):
# create a throwaway pool which
# has the effect of initializing
# class-level event listeners on Pool,
# if not present already.
p1 = QueuePool(creator=self.Connection, pool_size=3, max_overflow=-1)
p1.connect()
global pool
pool = QueuePool(creator=self.Connection, pool_size=3, max_overflow=-1)
@profiling.function_call_count()
def test_first_connect(self):
pool.connect()
def test_second_connect(self):
conn = pool.connect()
conn.close()
@profiling.function_call_count()
def go():
conn2 = pool.connect()
return conn2
go()
|