暂停/继续Azure Blob存储中的文件上载

mspsb9vt  于 2022-12-14  发布在  其他
关注(0)|答案(1)|浏览(178)

下面是我代码:

async def uploadin_files(file_path):
    for files_to_upload in file_path:
        time.sleep(2)
        blob_client = blob_service_client.get_blob_client(container=azure_container, blob=files_to_upload)
        with open(files_to_upload, 'rb') as datax:
            chunk_data_original = datax.read()
            test = blob_client.upload_blob(chunk_data_original, overwrite=True)
            
            print(files_to_upload,"Done uploading",test)

await uploadin_files(file_path_main)

我想在上传时暂停和恢复文件,有没有可能的方法或没有办法?

ubof19bj

ubof19bj1#

我可以使用下面的代码终止函数:

def overall_function(b):
    asyncio.run(upload_data("a"))

 def terminate_function():
    event = multiprocessing.Event()
    #blob_function = asyncio.run(upload_data("a")) 
    process = multiprocessing.Process(target=overall_function,args=(event,))
    process.start()
    time.sleep(10)
    process.terminate()
    print("Process terminated",process)
    return Response("terminated")

但是我如何按预期暂停/恢复功能。

相关问题