Skip to content

Commit

Permalink
Merge pull request #45 from NREL/pp/fix_loading
Browse files Browse the repository at this point in the history
Fix scraping on Unix systems
  • Loading branch information
ppinchuk authored Jan 10, 2025
2 parents 6346376 + 9bc8974 commit 32ab005
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion elm/cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# fmt: off
"""ELM Ordinances CLI."""
import sys
import json
import click
import asyncio
import logging
import multiprocessing

from elm.version import __version__
from elm.ords.process import process_counties_with_openai
Expand Down Expand Up @@ -37,6 +37,12 @@ def ords(config, verbose):
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
logger.setLevel(config.get("log_level", "INFO"))

# Need to set start method to "spawn" instead of "fork" for unix
# systems. If this call is not present, software hangs when process
# pool executor is launched.
# More info here: https://stackoverflow.com/a/63897175/20650649
multiprocessing.set_start_method('spawn')

# asyncio.run(...) doesn't throw exceptions correctly for some reason...
loop = asyncio.get_event_loop()
loop.run_until_complete(process_counties_with_openai(**config))
Expand Down

0 comments on commit 32ab005

Please # to comment.