MCPcopy
hub / github.com/scrapy/scrapy / connectionLost

Method connectionLost

scrapy/core/http2/protocol.py:350–374  ·  view source on GitHub ↗

Called by Twisted when the transport connection is lost. No need to write anything to transport here.

(self, reason: Failure = connectionDone)

Source from the content-addressed store, hash-verified

348 )
349
350 def connectionLost(self, reason: Failure = connectionDone) -> None:
351 """Called by Twisted when the transport connection is lost.
352 No need to write anything to transport here.
353 """
354 # Cancel the timeout if not done yet
355 self.setTimeout(None) # type: ignore[no-untyped-call]
356
357 # Notify the connection pool instance such that no new requests are
358 # sent over current connection
359 if not reason.check(connectionDone):
360 self._conn_lost_errors.append(reason)
361
362 self._conn_lost_deferred.callback(self._conn_lost_errors)
363
364 for stream in self.streams.values():
365 if stream.metadata["request_sent"]:
366 close_reason = StreamCloseReason.CONNECTION_LOST
367 else:
368 close_reason = StreamCloseReason.INACTIVE
369 stream.close(close_reason, self._conn_lost_errors, from_protocol=True)
370
371 self.metadata["active_streams"] -= len(self.streams)
372 self.streams.clear()
373 self._pending_request_stream_pool.clear()
374 self.conn.close_connection()
375
376 def _handle_events(self, events: list[Event]) -> None:
377 """Private method which acts as a bridge between the events

Callers

nothing calls this directly

Calls 5

checkMethod · 0.80
callbackMethod · 0.80
valuesMethod · 0.80
clearMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected