Skip to content

Commit

Permalink
Fix of bug introduced for per thread warnings.
Browse files Browse the repository at this point in the history
Additional try catch in as_bufr.
  • Loading branch information
david-i-berry committed Feb 16, 2024
1 parent 34f2b8d commit ac3a77a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions csv2bufr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,13 @@ def as_bufr(self, use_cached: bool = False) -> bytes:
# set delayed replications, this is needed again as we only used it the
# first time to set the keys
if len(self.delayed_replications) > 0:
codes_set_array(bufr_msg,
"inputDelayedDescriptorReplicationFactor",
self.delayed_replications)
try:
codes_set_array(bufr_msg,
"inputDelayedDescriptorReplicationFactor",
self.delayed_replications)
except Exception as e:
msg = "Error ({e}) setting inputDelayedDescriptorReplicationFactor" # noqa
raise RuntimeError(msg)
# ============================
# iterate over keys and encode
# ============================
Expand Down Expand Up @@ -973,6 +977,6 @@ def transform(data: str, mappings: dict) -> Iterator[dict]:
# now yield result back to caller
yield result
# clear warnings
del _warnings_global[job_id]
_warnings_global[job_id] = []

fh.close()

0 comments on commit ac3a77a

Please sign in to comment.