MCPcopy Create free account
hub / github.com/EasyIME/PIME / _process_queue

Method _process_queue

python/python3/tornado/curl_httpclient.py:216–255  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

214 self._process_queue()
215
216 def _process_queue(self) -> None:
217 while True:
218 started = 0
219 while self._free_list and self._requests:
220 started += 1
221 curl = self._free_list.pop()
222 (request, callback, queue_start_time) = self._requests.popleft()
223 # TODO: Don't smuggle extra data on an attribute of the Curl object.
224 curl.info = { # type: ignore
225 "headers": httputil.HTTPHeaders(),
226 "buffer": BytesIO(),
227 "request": request,
228 "callback": callback,
229 "queue_start_time": queue_start_time,
230 "curl_start_time": time.time(),
231 "curl_start_ioloop_time": self.io_loop.current().time(), # type: ignore
232 }
233 try:
234 self._curl_setup_request(
235 curl,
236 request,
237 curl.info["buffer"], # type: ignore
238 curl.info["headers"], # type: ignore
239 )
240 except Exception as e:
241 # If there was an error in setup, pass it on
242 # to the callback. Note that allowing the
243 # error to escape here will appear to work
244 # most of the time since we are still in the
245 # caller's original stack frame, but when
246 # _process_queue() is called from
247 # _finish_pending_requests the exceptions have
248 # nowhere to go.
249 self._free_list.append(curl)
250 callback(HTTPResponse(request=request, code=599, error=e))
251 else:
252 self._multi.add_handle(curl)
253
254 if not started:
255 break
256
257 def _finish(
258 self,

Callers 2

fetch_implMethod · 0.95

Calls 6

_curl_setup_requestMethod · 0.95
HTTPResponseClass · 0.90
timeMethod · 0.80
currentMethod · 0.80
callbackFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected