Skip to content

Commit f8faf95

Browse files
authored
Merge pull request #98 from lincc-frameworks/fix-count-dask-shutdown
Don't discard count results when Dask shutdown hangs
2 parents e8516ff + 40bf98b commit f8faf95

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

scripts/count_trainable_lcs.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,17 @@ def main(argv=None):
177177

178178
try:
179179
table = count_trainable_lcs(survey_config)
180+
# Print before tearing down the cluster: on shared clusters
181+
# client.close() can hang and raise TimeoutError, which would
182+
# otherwise discard the already-computed result.
183+
print(f"Trainable light curves for {survey_config.catalog_root}, n_src >= {survey_config.n_src}:")
184+
print(table.to_string(index=False))
180185
finally:
181186
if client is not None:
182-
client.close()
183-
184-
print(f"Trainable light curves for {survey_config.catalog_root}, n_src >= {survey_config.n_src}:")
185-
print(table.to_string(index=False))
187+
try:
188+
client.close()
189+
except Exception as exc: # noqa: BLE001
190+
print(f"Warning: ignoring error during Dask client shutdown: {exc!r}")
186191

187192

188193
if __name__ == "__main__":

0 commit comments

Comments
 (0)