This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # /// script | |
| # requires-python = ">=3.8" | |
| # dependencies = [ | |
| # "httpx>=0.27.0", | |
| # "pyarrow>=14.0.0", | |
| # "h2>=4.3.0" | |
| # ] | |
| # /// | |
| import argparse | |
| import asyncio | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import logging | |
| from contextlib import asynccontextmanager | |
| from functools import lru_cache | |
| from typing import AsyncIterator, Optional | |
| from sqlalchemy.ext.asyncio import ( | |
| AsyncEngine, | |
| AsyncSession, | |
| async_sessionmaker, | |
| create_async_engine, | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from psycopg2.pool import ThreadedConnectionPool as _ThreadedConnectionPool | |
| from concurrent.futures import ThreadPoolExecutor, as_completed | |
| from threading import Semaphore | |
| import pandas as pd | |
| import numpy as np | |
| import pickle | |
| NUM_WORKERS = 10 | |
| class ThreadedConnectionPool(_ThreadedConnectionPool): | 
