keyboard interrupt does not kill the download loop cleanly
Cadair opened this issue · comments
In a jupyter notebook, because the loop is running in a threadpool, this means that the download isn't cancelled at all. In a regular session it causes all the coroutines to fail with a KeyboardInterrupt
exception.
Thoughts on implementing this:
- We can react to the signal with
event_loop.add_signal_handler
. - The event handler should cleanly terminate all pending and all running task, by calling
Task.cancel
(addressing #61 should mean we always have aTask
object to cancel). - This should involve removing any part-finished files from disk so that there aren't corrupt files left lying around.
- When a
Task
is cancelled it throws aCancelledError
. This would need to be caught in_get_http
and_get_ftp
to cleanly terminate the task.