userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
pool.py
1
import
contextlib
2
import
typing
3
4
import
psycopg2.extensions
5
import
psycopg2.pool
6
7
8
class
AutocommitConnectionPool
:
9
def
__init__(self, minconn: int, maxconn: int, uri: str) ->
None
:
10
self.
_pool
= psycopg2.pool.ThreadedConnectionPool(minconn, maxconn, uri)
11
12
@contextlib.contextmanager
13
def
get_connection(
14
self,
15
) -> typing.Generator[psycopg2.extensions.connection, None, None]:
16
conn = self.
_pool
.getconn()
17
conn.autocommit =
True
18
19
try
:
20
yield
conn
21
finally
:
22
self.
_pool
.putconn(conn)
23
24
def
close(self) -> None:
25
self.
_pool
.closeall()
en
testsuite
databases
pgsql
pool.py
Generated on
for userver by
Doxygen
1.17.0