|
1 | 1 | import ssl |
| 2 | +import sys |
2 | 3 | from types import TracebackType |
3 | 4 | from typing import AsyncIterable, AsyncIterator, List, Optional, Type |
4 | 5 |
|
@@ -44,7 +45,7 @@ class AsyncConnectionPool(AsyncRequestInterface): |
44 | 45 | def __init__( |
45 | 46 | self, |
46 | 47 | ssl_context: ssl.SSLContext = None, |
47 | | - max_connections: int = 10, |
| 48 | + max_connections: Optional[int] = 10, |
48 | 49 | max_keepalive_connections: int = None, |
49 | 50 | keepalive_expiry: float = None, |
50 | 51 | http1: bool = True, |
@@ -81,17 +82,21 @@ def __init__( |
81 | 82 | uds: Path to a Unix Domain Socket to use instead of TCP sockets. |
82 | 83 | network_backend: A backend instance to use for handling network I/O. |
83 | 84 | """ |
84 | | - if max_keepalive_connections is None: |
85 | | - max_keepalive_connections = max_connections |
86 | | - |
87 | 85 | if ssl_context is None: |
88 | 86 | ssl_context = default_ssl_context() |
89 | 87 |
|
90 | 88 | self._ssl_context = ssl_context |
91 | 89 |
|
92 | | - self._max_connections = max_connections |
| 90 | + self._max_connections = ( |
| 91 | + sys.maxsize if max_connections is None else max_connections |
| 92 | + ) |
| 93 | + self._max_keepalive_connections = ( |
| 94 | + sys.maxsize |
| 95 | + if max_keepalive_connections is None |
| 96 | + else max_keepalive_connections |
| 97 | + ) |
93 | 98 | self._max_keepalive_connections = min( |
94 | | - max_keepalive_connections, max_connections |
| 99 | + self._max_connections, self._max_keepalive_connections |
95 | 100 | ) |
96 | 101 |
|
97 | 102 | self._keepalive_expiry = keepalive_expiry |
@@ -209,7 +214,7 @@ async def handle_async_request(self, request: Request) -> Response: |
209 | 214 | ) |
210 | 215 | if scheme not in ("http", "https"): |
211 | 216 | raise UnsupportedProtocol( |
212 | | - "Request URL has an unsupported protocol '{scheme}://'." |
| 217 | + f"Request URL has an unsupported protocol '{scheme}://'." |
213 | 218 | ) |
214 | 219 |
|
215 | 220 | status = RequestStatus(request) |
|
0 commit comments