Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: terminate early on first counterexample with --early-exit (#243)
The --early-exit flag is now properly handled to ensure that Halmos terminates immediately after finding the first counterexample, avoiding the reporting of multiple counterexamples. The previous implementation used a busy-waiting loop with time.sleep(1) to wait for the first counterexample or all futures to complete, which was inefficient and allowed multiple counterexamples to accumulate. The updated code introduces an early_exit flag variable to keep track of whether an early exit is requested. When a counterexample is found and --early-exit is set, the early_exit flag is set to True. The future_callback function checks this flag and immediately returns if it is True, preventing further processing of results. The thread pool is shut down after all the submitted futures have completed or been canceled, ensuring a clean termination.
- Loading branch information