(
self,
addrs: Iterator[Tuple[socket.AddressFamily, Tuple]],
af: socket.AddressFamily,
addr: Tuple,
future: "Future[IOStream]",
)
| 131 | ) |
| 132 | |
| 133 | def on_connect_done( |
| 134 | self, |
| 135 | addrs: Iterator[Tuple[socket.AddressFamily, Tuple]], |
| 136 | af: socket.AddressFamily, |
| 137 | addr: Tuple, |
| 138 | future: "Future[IOStream]", |
| 139 | ) -> None: |
| 140 | self.remaining -= 1 |
| 141 | try: |
| 142 | stream = future.result() |
| 143 | except Exception as e: |
| 144 | if self.future.done(): |
| 145 | return |
| 146 | # Error: try again (but remember what happened so we have an |
| 147 | # error to raise in the end) |
| 148 | self.last_error = e |
| 149 | self.try_connect(addrs) |
| 150 | if self.timeout is not None: |
| 151 | # If the first attempt failed, don't wait for the |
| 152 | # timeout to try an address from the secondary queue. |
| 153 | self.io_loop.remove_timeout(self.timeout) |
| 154 | self.on_timeout() |
| 155 | return |
| 156 | self.clear_timeouts() |
| 157 | if self.future.done(): |
| 158 | # This is a late arrival; just drop it. |
| 159 | stream.close() |
| 160 | else: |
| 161 | self.streams.discard(stream) |
| 162 | self.future.set_result((af, addr, stream)) |
| 163 | self.close_streams() |
| 164 | |
| 165 | def set_timeout(self, timeout: float) -> None: |
| 166 | self.timeout = self.io_loop.add_timeout( |
nothing calls this directly
no test coverage detected