MCPcopy Index your code
hub / github.com/ryanmcgrath/twython / _send

Method _send

twython/streaming/api.py:106–134  ·  view source on GitHub ↗
(retry_counter)

Source from the content-addressed store, hash-verified

104 params, _ = _transparent_params(params)
105
106 def _send(retry_counter):
107 requests_args = {}
108 for k, v in self.client_args.items():
109 # Maybe this should be set as a class
110 # variable and only done once?
111 if k in ('timeout', 'allow_redirects', 'verify'):
112 requests_args[k] = v
113
114 while self.connected:
115 try:
116 if method == 'get':
117 requests_args['params'] = params
118 else:
119 requests_args['data'] = params
120
121 response = func(url, **requests_args)
122 except requests.exceptions.Timeout:
123 self.on_timeout()
124 else:
125 if response.status_code != 200:
126 self.on_error(response.status_code, response.content, response.headers)
127
128 if self.retry_count and \
129 (self.retry_count - retry_counter) > 0:
130 time.sleep(self.retry_in)
131 retry_counter += 1
132 _send(retry_counter)
133
134 return response
135
136 while self.connected:
137 response = _send(retry_counter)

Callers

nothing calls this directly

Calls 2

on_timeoutMethod · 0.95
on_errorMethod · 0.95

Tested by

no test coverage detected