Skip to content

Commit

Permalink
Adding exception handling for different errors on Gzip files.
Browse files Browse the repository at this point in the history
Adding exception tasks to properly close multiprocessing pools.
  • Loading branch information
sunset666 committed Apr 15, 2024
1 parent 93a301c commit 92d305f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ingest_validation_tests/fastq_validator_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def validate_fastq_file(self, fastq_file: Path) -> None:
except IOError:
self.errors.append(self._format_error(f"Unable to open FASTQ data file {fastq_file}."))
return
except EOFError:
self.errors.append(self._format_error(f"EOF in FASTQ data file {fastq_file}."))
except Exception as e:
self.errors.append(self._format_error(f"Unexpected error: {e} on data file {fastq_file}."))
self._file_record_counts[str(fastq_file)] = records_read

def validate_fastq_files_in_path(self, paths: List[Path], threads: int) -> None:
Expand All @@ -192,6 +196,9 @@ def validate_fastq_files_in_path(self, paths: List[Path], threads: int) -> None:
data_output = pool.imap_unordered(engine, file_list)
except Exception as e:
_log(f"Error {e}")
pool.close()
pool.join()
data_found_one.append(f"Error {e}")
else:
pool.close()
pool.join()
Expand Down
3 changes: 3 additions & 0 deletions src/ingest_validation_tests/gz_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def collect_errors(self, **kwargs) -> List[str]:
data_output = pool.imap_unordered(engine, file_list)
except Exception as e:
_log(f"Error {e}")
pool.close()
pool.join()
data_output2.extend(f"Error: {e}")
else:
pool.close()
pool.join()
Expand Down

0 comments on commit 92d305f

Please sign in to comment.