Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I cancel an active boto3 s3 file_download?

I'm using boto3 to download files from an s3 bucket & I need to support canceling an active file transfer in my client UI - but I can't find how to do it.

There is a progress callback that I can use for transfer status, but I can not cancel the transfer from there.

I did find that boto3's s3transfer.TransferManager object has a .shutdown() member, but it is buggy (.shutdown() passes the wrong params to ._shutdown() a few lines below it) & crashes.

Is there another way to safely cancel an active file_download?

like image 892
Jason De Arte Avatar asked Oct 20 '19 03:10

Jason De Arte


2 Answers

I apologize as I do not have enough rep to post a comment, I wanted to point you towards the S3Control docs, as it appears that you might be able to schedule the download operations as jobs and then also use update_job_status(**kwargs) to cancel the job should it no longer be needed. I have not tested this, so feel free to downvote if not useful.

edit: I have enough rep to comment on future questions, thanks fam.

like image 109
Token Joe Avatar answered Sep 28 '22 12:09

Token Joe


Can you kill the process associated with the file?

kill $(ps -ef | grep 'process-name' | awk '{print $2}')

like image 40
Trevor Burke Avatar answered Sep 28 '22 11:09

Trevor Burke