MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / prefill_remote_browser_pool

Method prefill_remote_browser_pool

src/services/flow_client.py:4445–4483  ·  view source on GitHub ↗

让本地 remote_browser 服务提前开始补池,尽量把取 token 等待搬到前面。

(
        self,
        project_id: str,
        action: str = "IMAGE_GENERATION",
        token_id: Optional[int] = None,
        *,
        cooldown_seconds: float = 8.0,
    )

Source from the content-addressed store, hash-verified

4443 return payload
4444
4445 async def prefill_remote_browser_pool(
4446 self,
4447 project_id: str,
4448 action: str = "IMAGE_GENERATION",
4449 token_id: Optional[int] = None,
4450 *,
4451 cooldown_seconds: float = 8.0,
4452 ) -> bool:
4453 """让本地 remote_browser 服务提前开始补池,尽量把取 token 等待搬到前面。"""
4454 if config.captcha_method != "remote_browser":
4455 return False
4456
4457 normalized_project = str(project_id or "").strip()
4458 normalized_action = str(action or "IMAGE_GENERATION").strip() or "IMAGE_GENERATION"
4459 if not normalized_project:
4460 return False
4461
4462 cache_key = f"{normalized_project}|{normalized_action}|{int(token_id or 0)}"
4463 now_value = time.monotonic()
4464 last_sent = float(self._remote_browser_prefill_last_sent.get(cache_key, 0.0) or 0.0)
4465 if (now_value - last_sent) < max(0.5, float(cooldown_seconds)):
4466 return False
4467
4468 try:
4469 await self._call_remote_browser_service(
4470 method="POST",
4471 path="/api/v1/prefill",
4472 json_data={
4473 "project_id": normalized_project,
4474 "action": normalized_action,
4475 "token_id": token_id,
4476 },
4477 timeout_override=3,
4478 )
4479 self._remote_browser_prefill_last_sent[cache_key] = now_value
4480 return True
4481 except Exception as e:
4482 debug_logger.log_warning(f"[reCAPTCHA RemoteBrowser] prefill 失败: {e}")
4483 return False
4484
4485 async def prefill_remote_browser_for_tokens(self, tokens: List[Any], action: str = "IMAGE_GENERATION") -> int:
4486 if config.captcha_method != "remote_browser":

Callers 2

handle_generationMethod · 0.80

Calls 2

log_warningMethod · 0.80

Tested by

no test coverage detected