Playwright's sync API binds its greenlet event loop to the creating thread. Sharing pre-warmed slots across threads caused "cannot switch to a different thread" panics under uvicorn. New design: each worker thread owns its own Playwright instance created lazily on first fetch_html() call. A registry dict keyed by thread-id lets stop() close all slots at shutdown. Removes ThreadPoolExecutor warmup and idle-cleanup daemon thread entirely. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| adapter.py | ||
| auth.py | ||
| browser_pool.py | ||
| categories.py | ||
| normaliser.py | ||
| query_builder.py | ||
| scraper.py | ||