Skip to content

Conversation

@phanimullapudi
Copy link

Description
This PR addresses issue #1382 by implementing proper keyboard interrupt handling for yfinance's download function, especially when using threaded downloads.

Problem
When running yf.download() with multiple tickers and threads enabled, keyboard interruptions (Ctrl+C) were not being properly caught, resulting in two issues:

  • The download couldn't be cleanly interrupted
  • The user had to press Ctrl+C multiple times or force-quit the application

Solution

  • Added a global flag to track cancellation requests
  • Implemented a signal handler for SIGINT (Ctrl+C)
  • Modified download logic to check for cancellation and gracefully exit
  • Ensured that partial results are returned to the user when interrupted
  • Added comprehensive tests to verify interrupt handling behavior

@phanimullapudi phanimullapudi marked this pull request as ready for review March 24, 2025 01:44
@ValueRaider
Copy link
Collaborator

Looks fine just move to dev branch #1084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants