1 Matching Annotations
  1. Dec 2023
    1. ThreadPoolExecutor.

      ```python from concurrent.futures import ThreadPoolExecutor, as_completed

      def main(): with ThreadPoolExecutor(max_workers=len(URLs)) as executor: tasks = {} for url in URLs: future = executor.submit(fetch_url, url) tasks[future] = url

          for future in as_completed(tasks):
              title = future.result()
              url = tasks[future]
              print(f"URL: {url}\nTitle: {title}")
      

      ```