|
18 | 18 | from urllib import getproxies |
19 | 19 |
|
20 | 20 |
|
21 | | -def _make_pool(parsed_dsn, http_proxy, https_proxy, ca_certs): |
22 | | - # Use http_proxy if scheme is https and https_proxy is not set |
23 | | - proxy = parsed_dsn.scheme == "https" and https_proxy or http_proxy |
24 | | - if not proxy: |
25 | | - proxy = getproxies().get(parsed_dsn.scheme) |
26 | | - |
27 | | - opts = { |
28 | | - "num_pools": 2, |
29 | | - "cert_reqs": "CERT_REQUIRED", |
30 | | - "ca_certs": ca_certs or certifi.where(), |
31 | | - } |
32 | | - |
33 | | - if proxy: |
34 | | - return urllib3.ProxyManager(proxy, **opts) |
35 | | - else: |
36 | | - return urllib3.PoolManager(**opts) |
37 | | - |
38 | | - |
39 | 21 | class Transport(object): |
40 | 22 | """Baseclass for all transports. |
41 | 23 |
|
@@ -90,15 +72,16 @@ def __init__(self, options): |
90 | 72 | Transport.__init__(self, options) |
91 | 73 | self._worker = BackgroundWorker() |
92 | 74 | self._auth = self.parsed_dsn.to_auth("sentry.python/%s" % VERSION) |
93 | | - self._pool = _make_pool( |
| 75 | + self._disabled_until = None |
| 76 | + self._retry = urllib3.util.Retry() |
| 77 | + self.options = options |
| 78 | + |
| 79 | + self._pool = self._make_pool( |
94 | 80 | self.parsed_dsn, |
95 | 81 | http_proxy=options["http_proxy"], |
96 | 82 | https_proxy=options["https_proxy"], |
97 | 83 | ca_certs=options["ca_certs"], |
98 | 84 | ) |
99 | | - self._disabled_until = None |
100 | | - self._retry = urllib3.util.Retry() |
101 | | - self.options = options |
102 | 85 |
|
103 | 86 | from sentry_sdk import Hub |
104 | 87 |
|
@@ -148,6 +131,26 @@ def _send_event(self, event): |
148 | 131 |
|
149 | 132 | self._disabled_until = None |
150 | 133 |
|
| 134 | + def _get_pool_options(self, ca_certs): |
| 135 | + return { |
| 136 | + "num_pools": 2, |
| 137 | + "cert_reqs": "CERT_REQUIRED", |
| 138 | + "ca_certs": ca_certs or certifi.where(), |
| 139 | + } |
| 140 | + |
| 141 | + def _make_pool(self, parsed_dsn, http_proxy, https_proxy, ca_certs): |
| 142 | + # Use http_proxy if scheme is https and https_proxy is not set |
| 143 | + proxy = parsed_dsn.scheme == "https" and https_proxy or http_proxy |
| 144 | + if not proxy: |
| 145 | + proxy = getproxies().get(parsed_dsn.scheme) |
| 146 | + |
| 147 | + opts = self._get_pool_options(ca_certs) |
| 148 | + |
| 149 | + if proxy: |
| 150 | + return urllib3.ProxyManager(proxy, **opts) |
| 151 | + else: |
| 152 | + return urllib3.PoolManager(**opts) |
| 153 | + |
151 | 154 | def capture_event(self, event): |
152 | 155 | hub = self.hub_cls.current |
153 | 156 |
|
|
0 commit comments