MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / test_ssl_connection_pool

Method test_ssl_connection_pool

tests/test_connect.py:1956–1979  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1954 self.loop.set_exception_handler(old_handler)
1955
1956 async def test_ssl_connection_pool(self):
1957 ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
1958 ssl_context.load_verify_locations(SSL_CA_CERT_FILE)
1959
1960 pool = await self.create_pool(
1961 host='localhost',
1962 user='ssl_user',
1963 database='postgres',
1964 min_size=5,
1965 max_size=10,
1966 ssl=ssl_context)
1967
1968 async def worker():
1969 async with pool.acquire() as con:
1970 self.assertEqual(await con.fetchval('SELECT 42'), 42)
1971
1972 with self.assertRaises(asyncio.TimeoutError):
1973 await con.execute('SELECT pg_sleep(5)', timeout=0.5)
1974
1975 self.assertEqual(await con.fetchval('SELECT 43'), 43)
1976
1977 tasks = [worker() for _ in range(100)]
1978 await asyncio.gather(*tasks)
1979 await pool.close()
1980
1981 async def test_executemany_uvloop_ssl_issue_700(self):
1982 ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)

Callers

nothing calls this directly

Calls 2

create_poolMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected