Skip to content

Commit

Permalink
Check for keyboard interrupt only on main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlees committed Dec 19, 2023
1 parent b5054ea commit ee62c0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/azure_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ jobs:
## For debugging
- name: Install and run_test.py
if: failure()
shell: bash -l {0}
run: |
python setup.py build_ext --debug install
- name: Setup tmate session
if: failure()
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
Expand Down
7 changes: 4 additions & 3 deletions src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ std::vector<Reference> create_sketches(
std::vector<std::runtime_error> errors;
#pragma omp parallel for schedule(dynamic, 5) num_threads(num_threads)
for (unsigned int i = 0; i < names.size(); i++) {
if (interrupt || PyErr_CheckSignals() != 0) {
interrupt = true;
} else {
if (!interrupt) {
try {
SeqBuf seq_in(files[i], kmer_lengths.back());
sketches[i] = Reference(names[i], seq_in, kmer_seeds, sketchsize64,
Expand All @@ -101,6 +99,9 @@ std::vector<Reference> create_sketches(

if (omp_get_thread_num() == 0) {
sketch_progress.tick_count(done_count);
if (PyErr_CheckSignals() != 0) {
interrupt = true;
}
}
}
sketch_progress.finalise();
Expand Down
4 changes: 2 additions & 2 deletions test/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
# create sketches
sys.stderr.write("Sketch smoke test\n")
subprocess.run("python ../sketchlib-runner.py sketch -l references.txt -o test_db -s 10000 -k 15,29,4 --cpus 1", shell=True, check=True)
#os.remove("test_db.h5")
#subprocess.run("python ../sketchlib-runner.py sketch -l references.txt -o test_db -s 10000 -k 15,29,4 --cpus 2", shell=True, check=True)
os.remove("test_db.h5")
subprocess.run("python ../sketchlib-runner.py sketch -l references.txt -o test_db -s 10000 -k 15,29,4 --cpus 2", shell=True, check=True)
subprocess.run("python ../sketchlib-runner.py sketch -l references.txt -o test_db_phased --codon-phased --cpus 1", shell=True, check=True)
subprocess.run("python ../sketchlib-runner.py sketch 12673_8#24.contigs_velvet.fa 12673_8#34.contigs_velvet.fa -o test_db_small -s 1000 --kmer 14", shell=True, check=True)
subprocess.run("python ../sketchlib-runner.py add random test_db --cpus 2", shell=True, check=True)
Expand Down

0 comments on commit ee62c0c

Please sign in to comment.