Skip to content

Commit

Permalink
Test simply wrapping original code
Browse files Browse the repository at this point in the history
  • Loading branch information
tfardet authored Dec 27, 2023
1 parent 8cfb62e commit 202b643
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pynsee/geodata/_get_geodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,27 @@ def _get_geodata(

try:
with multiprocessing.Pool(
initializer=func_settings, initargs=(args,), processes=Nprocesses
) as pool:
initializer=_set_global_var,
initargs=(args,),
processes=Nprocesses,
) as pool:
list_output = list(
tqdm.tqdm(
pool.imap(func, irange),
total=length
pool.imap(_get_data_with_bbox2, irange),
total=len(list_bbox),
)
)
except Exception:
func_settings(args)
msg = "Multiprocessing failed in the geodata collection, " \
"using a traditional loop instead"

logger.warning(msg)

_set_global_var(args)
list_output = []

for p in tqdm.trange(length):
list_output.append(func(p))

msg = """
Multiprocessing failed in the geodata collection,
a traditional loop was used instead
"""
logger.warning(msg)
list_output.append(_get_data_with_bbox2(p))

data_all = pd.concat(list_output).reset_index(drop=True)
elif len(json) != 0:
Expand Down

0 comments on commit 202b643

Please sign in to comment.