MCPcopy
hub / github.com/scrapy/scrapy / close

Method close

scrapy/core/downloader/handlers/http11.py:138–158  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
161class TunnelError(Exception):

Callers

nothing calls this directly

Calls 2

maybe_deferred_to_futureFunction · 0.90
cancelMethod · 0.45

Tested by

no test coverage detected