(self)
| 136 | raise |
| 137 | |
| 138 | async def close(self) -> None: |
| 139 | from twisted.internet import reactor |
| 140 | |
| 141 | d: Deferred[None] = self._pool.closeCachedConnections() |
| 142 | # closeCachedConnections will hang on network or server issues, so |
| 143 | # we'll manually timeout the deferred. |
| 144 | # |
| 145 | # Twisted issue addressing this problem can be found here: |
| 146 | # https://github.com/twisted/twisted/issues/7738 |
| 147 | # |
| 148 | # closeCachedConnections doesn't handle external errbacks, so we'll |
| 149 | # issue a callback after `_disconnect_timeout` seconds. |
| 150 | # |
| 151 | # See also https://github.com/scrapy/scrapy/issues/2653 |
| 152 | delayed_call = reactor.callLater(self._disconnect_timeout, d.callback, ()) |
| 153 | |
| 154 | try: |
| 155 | await maybe_deferred_to_future(d) |
| 156 | finally: |
| 157 | if delayed_call.active(): |
| 158 | delayed_call.cancel() |
| 159 | |
| 160 | |
| 161 | class TunnelError(Exception): |
nothing calls this directly
no test coverage detected