Added __aenter__/__aexit__ requirement to CamoufoxManager for memory cleanup.

This commit is contained in:
Luciabrightcode 2025-12-22 17:34:51 +08:00
parent bd47e994d5
commit ef370dacff

View file

@ -18,6 +18,7 @@ Implement the core logic for the "Headless-Plus" architecture:
- Launch Camoufox (via Playwright) with specific `user_agent` and `viewport`. - Launch Camoufox (via Playwright) with specific `user_agent` and `viewport`.
- `initialize()`: Set up browser context. - `initialize()`: Set up browser context.
- `extract_session_state()`: Gather cookies, storage, and fingerprint info into `SessionState`. - `extract_session_state()`: Gather cookies, storage, and fingerprint info into `SessionState`.
- **Safety**: Implement `__aenter__` and `__aexit__` for aggressively reclaiming memory (close context/page).
### Extractor Tier ### Extractor Tier
#### [NEW] [src/extractor/client.py](file:///home/kasm-user/workspace/FAEA/src/extractor/client.py) #### [NEW] [src/extractor/client.py](file:///home/kasm-user/workspace/FAEA/src/extractor/client.py)
@ -29,11 +30,8 @@ Implement the core logic for the "Headless-Plus" architecture:
### Testing Infrastructure ### Testing Infrastructure
#### [NEW] [tests/e2e/test_handover.py](file:///home/kasm-user/workspace/FAEA/tests/e2e/test_handover.py) #### [NEW] [tests/e2e/test_handover.py](file:///home/kasm-user/workspace/FAEA/tests/e2e/test_handover.py)
- A full flow test: - **TLS Verification**: The automated test will likely use a local mock for Header/Cookie verification.
1. Instantiate `CamoufoxManager` -> Navigate to Mock Server -> Extract State. - **Manual JA3 Verification**: A separate script `tests/manual/verify_tls.py` will be created to hit an external service (e.g., `https://tls.peet.ws/api/all`) to print and compare JA3 hashes from both Camoufox and CurlClient. This addresses the "High Risk" feedback by acknowledging external dependency for true TLS verification.
2. Save State to Redis.
3. Instantiate `CurlClient` with State -> Request Mock Server.
4. **Verify**: Mock Server sees matching `User-Agent` and (if possible) consistent TLS signatures.
## Verification Plan ## Verification Plan