MCPcopy
hub / github.com/tornadoweb/tornado / on_connect_done

Method on_connect_done

tornado/tcpclient.py:133–163  ·  view source on GitHub ↗
(
        self,
        addrs: Iterator[Tuple[socket.AddressFamily, Tuple]],
        af: socket.AddressFamily,
        addr: Tuple,
        future: "Future[IOStream]",
    )

Source from the content-addressed store, hash-verified

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(

Callers

nothing calls this directly

Calls 8

try_connectMethod · 0.95
on_timeoutMethod · 0.95
clear_timeoutsMethod · 0.95
close_streamsMethod · 0.95
resultMethod · 0.80
doneMethod · 0.45
remove_timeoutMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected