| skipped 12 lines |
13 | 13 | | from typing import Tuple, Optional, Dict, List |
14 | 14 | | from urllib.parse import quote |
15 | 15 | | |
16 | | - | import aiohttp |
17 | 16 | | import aiodns |
18 | 17 | | import tqdm.asyncio |
19 | | - | from aiohttp_socks import ProxyConnector |
20 | 18 | | from python_socks import _errors as proxy_errors |
21 | 19 | | from socid_extractor import extract |
| 20 | + | from aiohttp import TCPConnector, ClientSession, http_exceptions |
22 | 21 | | from aiohttp.client_exceptions import ServerDisconnectedError, ClientConnectorError |
23 | 22 | | |
24 | 23 | | from .activation import ParsingActivator, import_aiohttp_cookies |
| skipped 35 lines |
60 | 59 | | cookie_jar = kwargs.get('cookie_jar') |
61 | 60 | | self.logger = kwargs.get('logger', Mock()) |
62 | 61 | | |
| 62 | + | # moved here to speed up the launch of Maigret |
| 63 | + | from aiohttp_socks import ProxyConnector |
| 64 | + | |
63 | 65 | | # make http client session |
64 | 66 | | connector = ( |
65 | | - | ProxyConnector.from_url(proxy) if proxy else aiohttp.TCPConnector(ssl=False) |
| 67 | + | ProxyConnector.from_url(proxy) if proxy else TCPConnector(ssl=False) |
66 | 68 | | ) |
67 | 69 | | connector.verify_ssl = False |
68 | | - | self.session = aiohttp.ClientSession( |
| 70 | + | self.session = ClientSession( |
69 | 71 | | connector=connector, trust_env=True, cookie_jar=cookie_jar |
70 | 72 | | ) |
71 | 73 | | |
| skipped 41 lines |
113 | 115 | | error = CheckError("Connecting failure", str(e)) |
114 | 116 | | except ServerDisconnectedError as e: |
115 | 117 | | error = CheckError("Server disconnected", str(e)) |
116 | | - | except aiohttp.http_exceptions.BadHttpMessage as e: |
| 118 | + | except http_exceptions.BadHttpMessage as e: |
117 | 119 | | error = CheckError("HTTP", str(e)) |
118 | 120 | | except proxy_errors.ProxyError as e: |
119 | 121 | | error = CheckError("Proxy", str(e)) |
| skipped 19 lines |
139 | 141 | | cookie_jar = kwargs.get('cookie_jar') |
140 | 142 | | self.logger = kwargs.get('logger', Mock()) |
141 | 143 | | |
| 144 | + | # moved here to speed up the launch of Maigret |
| 145 | + | from aiohttp_socks import ProxyConnector |
| 146 | + | |
142 | 147 | | connector = ProxyConnector.from_url(proxy) |
143 | 148 | | connector.verify_ssl = False |
144 | | - | self.session = aiohttp.ClientSession( |
| 149 | + | self.session = ClientSession( |
145 | 150 | | connector=connector, trust_env=True, cookie_jar=cookie_jar |
146 | 151 | | ) |
147 | 152 | | |
| skipped 735 lines |