batch_processor module

ziptimezone.batch_processor.get_lat_long_for_many_zips(zip_codes, max_workers=None)[source]

Processes a list of ZIP codes in parallel using ThreadPoolExecutor, retrieving latitudes and longitudes for each. The number of workers can be customized.

Parameters:
  • zip_codes (list of str) – A list of ZIP codes.

  • max_workers (int, optional) – Maximum number of threads to use for parallel processing.

Returns:

A dictionary mapping ZIP codes to their corresponding latitudes and longitudes.

Return type:

dict

ziptimezone.batch_processor.get_timezone_for_many_zips(zip_codes, max_workers=None)[source]

Processes a list of ZIP codes in parallel using ThreadPoolExecutor, retrieving time zones for each. The number of workers can be customized based on the machine.

Parameters:
  • zip_codes (list of str) – A list of ZIP codes.

  • max_workers (int, optional) – Maximum number of threads to use for parallel processing. If None, it defaults to the number of processors on the machine, times two.

Returns:

A dictionary mapping ZIP codes to their corresponding time zones or None if an error occurred.

Return type:

dict

ziptimezone.batch_processor.process_zip_code(zip_code)[source]

Helper function to process a single ZIP code and handle exceptions.

ziptimezone.batch_processor.process_zip_code_lat_long(zip_code)[source]

Helper function to process a single ZIP code for latitude and longitude.