Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Ctrl+C is not handled properly (or: how to pause the download before it is resumed?) #6

Open
rwiesbach opened this issue Aug 29, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@rwiesbach
Copy link

Hi,

on Ctrl+C I and likely most users would expect a graceful close (like end all current transfers and cleanly exit), especially as you highlight the ability to resume an interrupted download.

If I do Ctrl+C during download in hibp-downloader it shows me Tracebacks, so unhandled excepctions.
It may end the current transfers properly/gracefully or not (the python.exe subprocesses are terminated, but I don't know whether this is done gracefully), but the main process is not terminated (until I do manually).

Given this unclean kind of termination I don't know whether I can be sure that after the resume all downloads of ranges are continued properly (or whether problems may occur like incomplete .gz files on disk that hibp-downlaoder may consider as downloaded just because the .gz exists even though it is incomplete)

Thanks

(Python 3.12.5 on Windows 10)

@github-staff github-staff deleted a comment from rwiesbach Aug 29, 2024
@ndejong
Copy link
Contributor

ndejong commented Aug 30, 2024

Thanks @github-staff in nixing the malware pusher comment above

@ndejong
Copy link
Contributor

ndejong commented Aug 30, 2024

@rwiesbach thanks for commenting on this.

I'd love to be able to fix this unclean shutdown issue, have taken a look at it a few times and can't really figure out how to best terminate the threads and queues cleanly - if you have suggestions please do make them.

With respect to it being clean when you restart - then yes it is clean even though the CTL-C shutdown looks messy - this is because the metadata file is only written after the sucessful download of the datafile - there maybe a race condition in-between writing the metadata file I guess.

@rwiesbach
Copy link
Author

I'd love to be able to fix this unclean shutdown issue, have taken a look at it a few times and can't really figure out how to best terminate the threads and queues cleanly - if you have suggestions please do make them.

In code or as a concept? with no python expertise I'd use threads instead of processes and a global variable that is only written by the monitor but checked by the workers. every n iteration or every n seconds the workers check this variable and if it has changed they terminate cleanly (end the current download and exit). if all workers are down, the monitor (/main) can terminate, too.

@ndejong
Copy link
Contributor

ndejong commented Dec 23, 2024

Yes, the concept is fine - it's putting just that into practice in Python code where things get sideways in a way I can't see how to resolve.

Open call to anyone that can cleanly sort this out - would be awesome

@ndejong ndejong added the help wanted Extra attention is needed label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants
@ndejong @rwiesbach and others