fix: 🐛 Quick Exit on keyboard interrupt
This commit is contained in:
@@ -9,6 +9,7 @@ wheels/
|
||||
# Virtual environments
|
||||
.venv
|
||||
|
||||
dat_other/*
|
||||
dat_files/*
|
||||
asc_files/*
|
||||
csv_files/*
|
||||
@@ -16,3 +17,5 @@ combined_files/*
|
||||
zone_inputs/*
|
||||
|
||||
*.tar.gz
|
||||
|
||||
generate_test_data.py
|
||||
@@ -72,8 +72,13 @@ class BatchNimrod:
|
||||
}
|
||||
|
||||
completed_count = 0
|
||||
try:
|
||||
for future in concurrent.futures.as_completed(future_to_file):
|
||||
completed_count += 1
|
||||
if completed_count % 10 == 0:
|
||||
logging.info(f'processed {completed_count} out of {total_files} files')
|
||||
except KeyboardInterrupt:
|
||||
logging.warning("KeyboardInterrupt received. Cancelling pending tasks...")
|
||||
executor.shutdown(wait=False, cancel_futures=True)
|
||||
raise
|
||||
|
||||
|
||||
@@ -152,6 +152,7 @@ class GenerateTimeseries:
|
||||
}
|
||||
|
||||
completed_count = 0
|
||||
try:
|
||||
for future in concurrent.futures.as_completed(future_to_file):
|
||||
file_results = future.result()
|
||||
if file_results:
|
||||
@@ -163,6 +164,10 @@ class GenerateTimeseries:
|
||||
completed_count += 1
|
||||
if completed_count % 100 == 0:
|
||||
print(f"Processed {completed_count}/{total_files} files")
|
||||
except KeyboardInterrupt:
|
||||
print("KeyboardInterrupt received. Cancelling pending tasks...")
|
||||
executor.shutdown(wait=False, cancel_futures=True)
|
||||
raise
|
||||
|
||||
# Write CSVs for each location
|
||||
print("Writing CSV files...")
|
||||
|
||||
Reference in New Issue
Block a user