简体   繁体   中英

Pause/Resume the file upload in azure blob storage

below is my code:

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)

I want to pause and resume the file while uploading, is there any possible way or no way?

I can terminate the function using below code:

 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")

But how do I pause/resume the function as intended.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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