Improve Ctrl+C responsiveness during future polling#2949
Open
lipeize689-prog wants to merge 1 commit into
Open
Improve Ctrl+C responsiveness during future polling#2949lipeize689-prog wants to merge 1 commit into
lipeize689-prog wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves how Sherlock responds to Ctrl+C during active username checks.
Previously, Sherlock could remain blocked while waiting for a single future to finish, which made interruption feel delayed during long-running searches. This change makes future polling more interruptible and adds cleanup for pending work when a keyboard interrupt occurs.
What changed
Changed future result handling in get_response() to use short-interval polling via request_future.result(timeout=0.1) instead of waiting indefinitely for a single future.
Preserved KeyboardInterrupt so user interruption is propagated instead of being absorbed into ordinary request error handling.
Added shutdown_request_session() to:
cancel not-yet-started futures when possible,
shut down the executor,
close the underlying requests session.
Updated the query flow in sherlock() so interruptions trigger cleanup before bubbling back to the main CLI flow.
Kept the main interrupt path centered around handler() and the CLI flow in main(), so users still receive a clear interruption message and exit path.
Why this matters
It improves interactive behavior during concurrent site checks by reducing the amount of time Sherlock can remain stuck waiting on a single future before reacting to Ctrl+C.
It does not forcibly terminate already-running worker threads, but it does:
reduce time spent blocking on one future,
make interruption more responsive,
and clean up pending work more reliably.
Testing
Added/used targeted tests covering:
KeyboardInterrupt propagation during future polling,
cancellation/cleanup logic in shutdown_request_session(),
main CLI interruption behavior through the updated Ctrl+C path.
Targeted test result:
6 passed, 7 deselected