简体   繁体   English

如何取消活动的 boto3 s3 file_download?

[英]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.我正在使用 boto3 从 s3 存储桶下载文件,并且我需要支持取消客户端 UI 中的活动文件传输 - 但我找不到如何做到这一点。

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.我确实发现 boto3 的s3transfer.TransferManager object 有一个.shutdown()成员,但它有问题(.shutdown() 将错误的参数传递给 ._shutdown() 下面几行)并崩溃。

Is there another way to safely cancel an active file_download?还有其他方法可以安全地取消活动的 file_download 吗?

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.抱歉,我没有足够的代表发表评论,我想向您指出S3Control文档,因为您似乎可以将下载操作安排为作业,然后还使用update_job_status(**kwargs)来如果不再需要该作业,请取消该作业。 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.编辑:我有足够的代表评论未来的问题,谢谢fam。

Can you kill the process associated with the file?你能杀死与文件关联的进程吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM