暂停/恢复在azure blob存储中的文件上传


下面是我的代码:
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)

我想在上传时暂停并恢复文件,有没有办法?

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

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

但是我如何按预期暂停/恢复函数呢?

相关内容

最新更新