MCPcopy Index your code
hub / github.com/aws/aws-cli / _tunnel

Method _tunnel

tests/integration/botocore/test_client_http.py:223–251  ·  view source on GitHub ↗
(self, client, remote)

Source from the content-addressed store, hash-verified

221 poll_limit = 10**4
222
223 def _tunnel(self, client, remote):
224 client.setblocking(0)
225 remote.setblocking(0)
226 sockets = [client, remote]
227 noop_count = 0
228 while True:
229 readable, writeable, _ = select.select(sockets, sockets, [], 1)
230 if client in readable and remote in writeable:
231 noop_count = 0
232 client_bytes = client.recv(self.tunnel_chunk_size)
233 if not client_bytes:
234 break
235 remote.sendall(client_bytes)
236 if remote in readable and client in writeable:
237 noop_count = 0
238 remote_bytes = remote.recv(self.tunnel_chunk_size)
239 if not remote_bytes:
240 break
241 client.sendall(remote_bytes)
242
243 if noop_count > self.poll_limit:
244 # We have a case where all communication has
245 # finished but we never saw an empty read.
246 # This will leave both sockets as writeable
247 # indefinitely. We'll force a break here if
248 # we've crossed our polling limit.
249 break
250
251 noop_count += 1
252
253 def do_CONNECT(self):
254 if not self.validate_auth():

Callers 6

do_CONNECTMethod · 0.95
do_CONNECTMethod · 0.80

Calls 1

sendallMethod · 0.45

Tested by

no test coverage detected