MCPcopy Create free account
hub / github.com/EasyIME/PIME / finish

Method finish

python/python3/tornado/http1connection.py:506–536  ·  view source on GitHub ↗

Implements `.HTTPConnection.finish`.

(self)

Source from the content-addressed store, hash-verified

504 return future
505
506 def finish(self) -> None:
507 """Implements `.HTTPConnection.finish`."""
508 if (
509 self._expected_content_remaining is not None
510 and self._expected_content_remaining != 0
511 and not self.stream.closed()
512 ):
513 self.stream.close()
514 raise httputil.HTTPOutputError(
515 "Tried to write %d bytes less than Content-Length"
516 % self._expected_content_remaining
517 )
518 if self._chunking_output:
519 if not self.stream.closed():
520 self._pending_write = self.stream.write(b"0\r\n\r\n")
521 self._pending_write.add_done_callback(self._on_write_complete)
522 self._write_finished = True
523 # If the app finished the request while we're still reading,
524 # divert any remaining data away from the delegate and
525 # close the connection when we're done sending our response.
526 # Closing the connection is the only way to avoid reading the
527 # whole input body.
528 if not self._read_finished:
529 self._disconnect_on_finish = True
530 # No more data is coming, so instruct TCP to send any remaining
531 # data immediately instead of waiting for a full packet or ack.
532 self.stream.set_nodelay(True)
533 if self._pending_write is None:
534 self._finish_request(None)
535 else:
536 future_add_done_callback(self._pending_write, self._finish_request)
537
538 def _on_write_complete(self, future: "Future[None]") -> None:
539 exc = future.exception()

Callers 2

_read_messageMethod · 0.45
finishMethod · 0.45

Calls 6

_finish_requestMethod · 0.95
future_add_done_callbackFunction · 0.90
closedMethod · 0.80
closeMethod · 0.45
writeMethod · 0.45
set_nodelayMethod · 0.45

Tested by

no test coverage detected