(self, addrs: Iterator[Tuple[socket.AddressFamily, Tuple]])
| 113 | return self.future |
| 114 | |
| 115 | def try_connect(self, addrs: Iterator[Tuple[socket.AddressFamily, Tuple]]) -> None: |
| 116 | try: |
| 117 | af, addr = next(addrs) |
| 118 | except StopIteration: |
| 119 | class="cm"># We've reached the end of our queue, but the other queue |
| 120 | class="cm"># might still be working. Send a final error on the future |
| 121 | class="cm"># only when both queues are finished. |
| 122 | if self.remaining == 0 and not self.future.done(): |
| 123 | self.future.set_exception( |
| 124 | self.last_error or IOError(class="st">"connection failed") |
| 125 | ) |
| 126 | return |
| 127 | stream, future = self.connect(af, addr) |
| 128 | self.streams.add(stream) |
| 129 | future_add_done_callback( |
| 130 | future, functools.partial(self.on_connect_done, addrs, af, addr) |
| 131 | ) |
| 132 | |
| 133 | def on_connect_done( |
| 134 | self, |
no test coverage detected