(self)
| 193 | self._process_queue() |
| 194 | |
| 195 | def _process_queue(self) -> None: |
| 196 | while True: |
| 197 | started = 0 |
| 198 | while self._free_list and self._requests: |
| 199 | started += 1 |
| 200 | curl = self._free_list.pop() |
| 201 | (request, callback, queue_start_time) = self._requests.popleft() |
| 202 | # TODO: Don't smuggle extra data on an attribute of the Curl object. |
| 203 | curl.info = { # type: ignore |
| 204 | "headers": httputil.HTTPHeaders(), |
| 205 | "buffer": BytesIO(), |
| 206 | "request": request, |
| 207 | "callback": callback, |
| 208 | "queue_start_time": queue_start_time, |
| 209 | "curl_start_time": time.time(), |
| 210 | "curl_start_ioloop_time": self.io_loop.current().time(), # type: ignore |
| 211 | } |
| 212 | try: |
| 213 | self._curl_setup_request( |
| 214 | curl, |
| 215 | request, |
| 216 | curl.info["buffer"], # type: ignore |
| 217 | curl.info["headers"], # type: ignore |
| 218 | ) |
| 219 | except Exception as e: |
| 220 | # If there was an error in setup, pass it on |
| 221 | # to the callback. Note that allowing the |
| 222 | # error to escape here will appear to work |
| 223 | # most of the time since we are still in the |
| 224 | # caller's original stack frame, but when |
| 225 | # _process_queue() is called from |
| 226 | # _finish_pending_requests the exceptions have |
| 227 | # nowhere to go. |
| 228 | curl.reset() |
| 229 | self._free_list.append(curl) |
| 230 | callback(HTTPResponse(request=request, code=599, error=e)) |
| 231 | else: |
| 232 | self._multi.add_handle(curl) |
| 233 | |
| 234 | if not started: |
| 235 | break |
| 236 | |
| 237 | def _finish( |
| 238 | self, |
no test coverage detected