Waits until a response is received for this request, records the Response object for it in self.response, and returns response.body. If no response was received from the other party before the channel closed, self.response is a synthesized Response with body=NoMoreMessages()
(self, raise_if_failed=True)
| 764 | return f"{self.seq} request {json.repr(self.command)} to {self.channel}" |
| 765 | |
| 766 | def wait_for_response(self, raise_if_failed=True): |
| 767 | """Waits until a response is received for this request, records the Response |
| 768 | object for it in self.response, and returns response.body. |
| 769 | |
| 770 | If no response was received from the other party before the channel closed, |
| 771 | self.response is a synthesized Response with body=NoMoreMessages(). |
| 772 | |
| 773 | If raise_if_failed=True and response.success is False, raises response.body |
| 774 | instead of returning. |
| 775 | """ |
| 776 | |
| 777 | with self.channel: |
| 778 | while self.response is None: |
| 779 | self.channel._handlers_enqueued.wait() |
| 780 | |
| 781 | if raise_if_failed and not self.response.success: |
| 782 | raise self.response.body |
| 783 | return self.response.body |
| 784 | |
| 785 | def on_response(self, response_handler): |
| 786 | """Registers a handler to invoke when a response is received for this request. |
no test coverage detected